The PR changes how invalid quantity values are handled for the
upload_max_filesize and post_max_size INI settings.
Currently, malformed values may be interpreted through the legacy
quantity parser. For example, upload_max_filesize=1GB may effectively be
interpreted as 1 byte by request_parse_body, while ini_get() still returns the
original string. A completely invalid value can also lead to unclear behavior.
(for example, empty string, which is an undefined behavior)
This makes configuration mistakes hard to diagnose and may result in PHP
enforcing a different limit than the one an administrator expects. (e.g. a 1 byte
upload maximum)
After the proposal, the invalid value is rejected in request_parse_body. And
in ini_get, we emit a warning, and use the defalu value instead.
For example:
upload_max_filesize=1GB
would now emit a warning and keep the default 2M value, instead of being
interpreted as 1. And is rejected with ValueError if parsed by
request_parse_body, instead of being interpreted as “1GB”.
Arguably this falls in line with https://wiki.php.net/rfc/policy-exempt-type-value-error-bc-policy
as some other extension INI setting better validate their values. However, as
this might cause bigger impact I am writing this to make sure nobody is
pushing back on this
The PR changes how invalid quantity values are handled for the
upload_max_filesize and post_max_size INI settings.
Currently, malformed values may be interpreted through the legacy
quantity parser. For example, upload_max_filesize=1GB may effectively be
interpreted as 1 byte by request_parse_body, while ini_get() still returns the
original string. A completely invalid value can also lead to unclear behavior.
(for example, empty string, which is an undefined behavior)
This makes configuration mistakes hard to diagnose and may result in PHP
enforcing a different limit than the one an administrator expects. (e.g. a 1 byte
upload maximum)
After the proposal, the invalid value is rejected in request_parse_body. And
in ini_get, we emit a warning, and use the defalu value instead.
For example:
upload_max_filesize=1GB
would now emit a warning and keep the default 2M value, instead of being
interpreted as 1. And is rejected with ValueError if parsed by
request_parse_body, instead of being interpreted as “1GB”.
Arguably this falls in line with https://wiki.php.net/rfc/policy-exempt-type-value-error-bc-policy
as some other extension INI setting better validate their values. However, as
this might cause bigger impact I am writing this to make sure nobody is
pushing back on this
I think the best way how to proceed would be to extend the policy RFC and add this there as well. It would be actually good because we could also extend it to add output types so this https://github.com/php/php-src/pull/22538 is not considered a BC break.