Skip to content

Accept php.ini style memory limits and reject too large values - #56

Merged
DavidBadura merged 1 commit into
1.6.xfrom
memory-limit-shorthand
Oct 2, 2026
Merged

DavidBadura merged 1 commit into
1.6.xfrom
memory-limit-shorthand

Conversation

@DavidBadura

Copy link
Copy Markdown
Member

memoryLimit now also accepts the php.ini shorthand units K, M and G next to KB, MB and GB, so passing something like --memory-limit=512M no longer fails with InvalidFormat.

Values that don't fit into an integer were not handled either: 99999999999GB threw a TypeError from the Bytes constructor, and a huge number without unit was silently capped at PHP_INT_MAX. Both now throw InvalidFormat. The check relies on PHP returning a float when the multiplication overflows, which keeps leading zeros like 0050MB working as before.

memoryLimit now also accepts K, M and G, so values like 512M from
php.ini work. Values that overflow an integer threw a TypeError or were
silently capped at PHP_INT_MAX, they now throw InvalidFormat.
@DavidBadura DavidBadura added this to the 1.6.0 milestone Oct 2, 2026
@DavidBadura DavidBadura added the enhancement New feature or request label Oct 2, 2026
@DavidBadura
DavidBadura merged commit b98385f into 1.6.x Oct 2, 2026
15 of 16 checks passed
@DavidBadura
DavidBadura deleted the memory-limit-shorthand branch October 2, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants