PHP does not report invalid values for file sizes and interpret them incorrectly
Description
There is no error message given if you accidentally use KB, MB or GB instead of K, M or G. and they will be evaluated to some other values. phpinfo() and ini_get() will report what you have written e.g. 1GB , so it will not be clear that there is anything wrong with your setting even though there is.
Expected behaviour: Show a notice/warning and revert to the default value.
Links: https://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes
PHP Version
7., 8.
Operating System
No response
The behavior is clearly documented:
The available options are K (for Kilobytes), M (for Megabytes) and G (for Gigabytes), and are all case-insensitive. Anything else assumes bytes.
That said, I don't know of a reason why zend_atol (I assume that's where the INI parser gets this from) couldn't also support GB/MB/KB, as I doubt anyone is currently using it and expecting to get byte values. On a related note, might be a good time to add support for T/TB.
If not then this is a doc issue: to explicitly call out the *Bs as not being supported.
@salarmehr yes, it assumes it byte but it does not show the "assumed" value on the PHP info page. It's better to not assume a wrong value and show some error message.
Somewhat related: zend_atol() parses 128ksomething as 128g.
This would be addressed by PR #7788 in a backward compatible way.
Related to #7951
Fixed in https://github.com/php/php-src/pull/7951 (PHP >= 8.2)