Allow usage of environment variables in PHP ini settings that contain byte size values - #544
Allow usage of environment variables in PHP ini settings that contain byte size values#544graste wants to merge 1 commit into
Conversation
|
@graste Thanks for looking into this, and for linking the downstream issue too. PHP's ini parser already interpolates Same from PHP 5.6 through 8.5. The bare The warning is PHP 8.2+, older versions accept it silently, but every version applies Error reporting for an invalid value could certainly be better. An undefined variable interpolates to an empty string, and Closing here, but happy to accept PRs to improve error reporting 👍 |
I ran into a problem where the
IniUtil::iniSizeToBytesfunction threw errors due to the usage of environment variables inside PHP ini settings to configure size values.Example:
This might be used e.g. in docker setups where the container gets
post_max_size,memory_limitetc values via environment variables instead of providing different ini files per environments via mounts.I suggest the changes within this pull request. I didn't add a changelog entry, as I don't know your rules for this. The used regular expression should work w/ PCRE and PCRE2 if I'm not mistaken. I didn't verify performance aspects, but usage of the function seems to be in constructors only. PS: That last string cast is not phpstan level 10 compatible. 🗡️