You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Configuring php in a docker container which is configurable via env I noticed strange behaviour when using ${ENV} in php-fpm config files for boolean values. The only values accepted are 1 and "" when I would expect no, yes, true, false etc. to be accepted. (I could not find a documentation somewhere which describes accepted values)
[01-Mar-2024 11:14:47] ERROR: [/etc/php-fpm.d/www.conf:5] unable to parse value for entry 'clear_env': invalid boolean value
[01-Mar-2024 11:14:47] ERROR: Unable to include /etc/php-fpm.d/www.conf from /etc/php-fpm.conf at line 5
[01-Mar-2024 11:14:47] ERROR: failed to load configuration file '/etc/php-fpm.conf'
[01-Mar-2024 11:14:47] ERROR: FPM initialization failed
The same applies for all boolean values, and I could eventually find the code which produces the above error in my attempt to get the container running with env variables:
staticchar*fpm_conf_set_boolean(zval*value, void**config, intptr_toffset) /* {{{ */
{
zend_string*val=Z_STR_P(value);
boolvalue_y=zend_string_equals_literal(val, "1");
boolvalue_n=ZSTR_LEN(val) ==0; /* Empty string is the only valid false value */if (!value_y&& !value_n) {
return"invalid boolean value";
}
* (int*) ((char*) *config+offset) =value_y ? 1 : 0;
returnNULL;
}
I just had a look and it is because FPM relies on conversion in zend_ini_scanner which converts the boolean values either to "1" or "". This is however not the case if value is supplied through the env variable which is copied as supplied. I need to think if this makes more sense to handle in INI or in FPM. I guess we can classify this as a bug even though it is somewhere between. But changing (fixing) it should not do any harm as it is currently not working.
Description
Configuring php in a docker container which is configurable via env I noticed strange behaviour when using
${ENV}
in php-fpm config files for boolean values. The only values accepted are1
and""
when I would expectno
,yes
,true
,false
etc. to be accepted. (I could not find a documentation somewhere which describes accepted values)The following code:
export PHP_FPM_CLEAR_ENV=true
/etc/php-fpm.d/www.conf
:Resulted in this output:
But I expected this output instead:
The same applies for all boolean values, and I could eventually find the code which produces the above error in my attempt to get the container running with env variables:
From https://github.com/php/php-src/blob/a48ed12ea9d3d59d307c77131092cff13acee2d0/sapi/fpm/fpm/fpm_conf.c#L213C1-L225C2
PHP Version
8.1.27
Operating System
Rocky Linux 9 (Docker
rockylinux:9
sha256:c944604c0c759f5d164ffbdf0bbab2fac582b739938937403c067ab634a0518a
)The text was updated successfully, but these errors were encountered: