Skip to content

FPM: php_value and php_admin_value entries are applied in reverse order [.phpt test included] #13249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dzuelke opened this issue Jan 26, 2024 · 2 comments
Assignees

Comments

@dzuelke
Copy link
Contributor

dzuelke commented Jan 26, 2024

Description

The following FPM config:

[global]
error_log = {{FILE:LOG}}
[unconfined]
listen = {{ADDR}}
pm = static
pm.max_children = 5
php_value[memory_limit]=32M
php_value[memory_limit]=24M
php_admin_value[date.timezone]=Europe/London
php_admin_value[date.timezone]=Europe/Paris

Resulted in this php-fpm -tt output:

…
[26-Jan-2024 07:24:03] NOTICE: 	php_value[memory_limit] = 24M
[26-Jan-2024 07:24:03] NOTICE: 	php_value[memory_limit] = 32M
[26-Jan-2024 07:24:03] NOTICE: 	php_admin_value[date.timezone] = Europe/Paris
[26-Jan-2024 07:24:03] NOTICE: 	php_admin_value[date.timezone] = Europe/London

But I expected this output instead:

…
[26-Jan-2024 07:24:03] NOTICE: 	php_value[memory_limit] = 32M
[26-Jan-2024 07:24:03] NOTICE: 	php_value[memory_limit] = 24M
[26-Jan-2024 07:24:03] NOTICE: 	php_admin_value[date.timezone] = Europe/London
[26-Jan-2024 07:24:03] NOTICE: 	php_admin_value[date.timezone] = Europe/Paris

Note

This is not just cosmetic ordering in php-fpm -tt; the values are also applied in this order as INI directives, so ini_get() will return 32M and Europe/London instead of the expected 24M and Europe/Paris.


PHPT:

<?php // this is just for GitHub syntax coloring ?>
--TEST--
FPM: GH-13249 - php_value and php_admin_value entries are applied in reverse order
--SKIPIF--
<?php include "skipif.inc"; ?>
--FILE--
<?php

require_once "tester.inc";

$cfg = <<<EOT
[global]
error_log = {{FILE:LOG}}
[unconfined]
listen = {{ADDR}}
pm = static
pm.max_children = 5
php_value[memory_limit]=32M
php_value[memory_limit]=24M
php_admin_value[date.timezone]=Europe/London
php_admin_value[date.timezone]=Europe/Paris
EOT;

$code = <<<EOT
<?php
echo "Test Start\n";
var_dump(ini_get('memory_limit'), ini_get('date.timezone'));
echo "Test End\n";
EOT;

$tester = new FPM\Tester($cfg, $code);
$tester->start();
$tester->expectLogStartNotices();
$tester->request()->expectBody([
    'Test Start',
    'string(3) "24M"',
    'string(12) "Europe/Paris"',
    'Test End'
]);
$tester->terminate();
$tester->close();

?>
Done
--EXPECT--
Done
--CLEAN--
<?php
require_once "tester.inc";
FPM\Tester::clean();
?>

Test log:

---- EXPECTED OUTPUT
Done
---- ACTUAL OUTPUT
>>> Response
----------------- OUT -----------------
X-Powered-By: PHP/8.3.2
Content-type: text/html; charset=UTF-8

Test Start
string(3) "32M"
string(13) "Europe/London"
Test End

----------------- ERR -----------------

---------------------------------------

ERROR: ==> The expected body:
Test Start
string(3) "24M"
string(12) "Europe/Paris"
Test End
==> does not match the actual body:
Test Start
string(3) "32M"
string(13) "Europe/London"
Test End

LOGS:
--------------------------------------------------------------------
[26-Jan-2024 08:55:34] NOTICE: fpm is running, pid 62872
[26-Jan-2024 08:55:34] NOTICE: ready to handle connections
--------------------------------------------------------------------

Done
---- FAILED

PHP Version

PHP 8.3.2

Operating System

No response

dzuelke added a commit to heroku/heroku-buildpack-php that referenced this issue Jan 26, 2024
Turns out that bug which would not allow overriding of FPM config php_value settings in .user.ini was fixed in... PHP 7.2: https://bugs.php.net/bug.php?id=75212

Also, that behavior where a later declaration does not override a newer one is probably a bug: php/php-src#13249

We now use php-fpm -tt to dump the config, since that will have stuff printed in evaluation order - if the bug above ever gets fixed, we have to do nothing.

This also removes the need for us to handle PHP-FPM config includes ourselves, including variable expansion or globbing - neither was supported until mnow.
dzuelke added a commit to heroku/heroku-buildpack-php that referenced this issue Jan 26, 2024
Turns out that bug which would not allow overriding of FPM config php_value settings in .user.ini was fixed in... PHP 7.2: https://bugs.php.net/bug.php?id=75212

Also, that behavior where a later declaration does not override a newer one is probably a bug: php/php-src#13249

We now use php-fpm -tt to dump the config, since that will have stuff printed in evaluation order - if the bug above ever gets fixed, we have to do nothing.

This also removes the need for us to handle the PHP-FPM config include directives ourselves, and as a result, variable expansion and globbing now work in these!
dzuelke added a commit to heroku/heroku-buildpack-php that referenced this issue Jan 26, 2024
Turns out that bug which would not allow overriding of FPM config php_value settings in .user.ini was fixed in... PHP 7.2: https://bugs.php.net/bug.php?id=75212

Also, that behavior where a later declaration does not override a newer one is probably a bug: php/php-src#13249

We now use php-fpm -tt to dump the config, since that will have stuff printed in evaluation order - if the bug above ever gets fixed, we have to do nothing.

This also removes the need for us to handle the PHP-FPM config include directives ourselves, and as a result, variable expansion and globbing now work in these!
dzuelke added a commit to heroku/heroku-buildpack-php that referenced this issue Jan 26, 2024
Turns out that bug which would not allow overriding of FPM config php_value settings in .user.ini was fixed in... PHP 7.2: https://bugs.php.net/bug.php?id=75212

Also, that behavior where a later declaration does not override a newer one is probably a bug: php/php-src#13249

We now use php-fpm -tt to dump the config, since that will have stuff printed in evaluation order - if the bug above ever gets fixed, we have to do nothing.

This also removes the need for us to handle the PHP-FPM config include directives ourselves, and as a result, variable expansion and globbing now work in these!
dzuelke added a commit to heroku/heroku-buildpack-php that referenced this issue Jan 26, 2024
Turns out that bug which would not allow overriding of FPM config php_value settings in .user.ini was fixed in... PHP 7.2: https://bugs.php.net/bug.php?id=75212

Also, that behavior where a later declaration does not override a newer one is probably a bug: php/php-src#13249

We now use php-fpm -tt to dump the config, since that will have stuff printed in evaluation order - if the bug above ever gets fixed, we have to do nothing.

This also removes the need for us to handle the PHP-FPM config include directives ourselves, and as a result, variable expansion and globbing now work in these!
dzuelke added a commit to heroku/heroku-buildpack-php that referenced this issue Jan 26, 2024
Turns out that bug which would not allow overriding of FPM config php_value settings in .user.ini was fixed in... PHP 7.2: https://bugs.php.net/bug.php?id=75212

Also, that behavior where a later declaration does not override a newer one is probably a bug: php/php-src#13249

We now use php-fpm -tt to dump the config, since that will have stuff printed in evaluation order - if the bug above ever gets fixed, we have to do nothing.

This also removes the need for us to handle the PHP-FPM config include directives ourselves, and as a result, variable expansion and globbing now work in these!
dzuelke added a commit to heroku/heroku-buildpack-php that referenced this issue Jan 30, 2024
Turns out that bug which would not allow overriding of FPM config php_value settings in .user.ini was fixed in... PHP 7.2: https://bugs.php.net/bug.php?id=75212

Also, that behavior where a later declaration does not override a newer one is probably a bug: php/php-src#13249

We now use php-fpm -tt to dump the config, since that will have stuff printed in evaluation order - if the bug above ever gets fixed, we have to do nothing.

This also removes the need for us to handle the PHP-FPM config include directives ourselves, and as a result, variable expansion and globbing now work in these!

GUS-W-14901875
dzuelke added a commit to heroku/heroku-buildpack-php that referenced this issue Jan 30, 2024
Turns out that bug which would not allow overriding of FPM config php_value settings in .user.ini was fixed in... PHP 7.2: https://bugs.php.net/bug.php?id=75212

Also, that behavior where a later declaration does not override a newer one is probably a bug: php/php-src#13249

We now use php-fpm -tt to dump the config, since that will have stuff printed in evaluation order - if the bug above ever gets fixed, we have to do nothing.

This also removes the need for us to handle the PHP-FPM config include directives ourselves, and as a result, variable expansion and globbing now work in these!

GUS-W-14901875
@bukka
Copy link
Member

bukka commented Feb 3, 2024

I'm aware of this and have got it on my list as one of the higher priorities. It might have some BC implications so might be potentially just for master.

Here are some related issues already reported (not all of them are the same like this one):

@dzuelke
Copy link
Contributor Author

dzuelke commented Feb 15, 2024

Yup agreed re: the potential BC implications, so master seems reasonable.

There is a suggestion in #8398 to make this configurable somehow; I don't think that's a good idea in terms of surface area of code to maintain in the future.

But it did make me wonder for a moment... what should the behavior be for php_admin_value? You could theoretically make that argument that the first declaration should win, and following declarations (e.g. from globbed includes) should not be able to override it once set? This way, a server admin can set a value that truly cannot be overridden.

But I'd argue that, in those kind of environments, you probably don't want users to have any control whatsoever over PHP_INI_SYSTEM level config directives, so you wouldn't give folks the ability to configure FPM directly anyway - that's what .user.ini and ini_set() are for.

So IMO, this should be fixed the same for php_value and php_admin_value - later declarations override earlier ones.

robinwo pushed a commit to robinwo/heroku-buildpack-php that referenced this issue Sep 13, 2024
Turns out that bug which would not allow overriding of FPM config php_value settings in .user.ini was fixed in... PHP 7.2: https://bugs.php.net/bug.php?id=75212

Also, that behavior where a later declaration does not override a newer one is probably a bug: php/php-src#13249

We now use php-fpm -tt to dump the config, since that will have stuff printed in evaluation order - if the bug above ever gets fixed, we have to do nothing.

This also removes the need for us to handle the PHP-FPM config include directives ourselves, and as a result, variable expansion and globbing now work in these!

GUS-W-14901875
robinwo pushed a commit to robinwo/heroku-buildpack-php that referenced this issue Sep 13, 2024
Turns out that bug which would not allow overriding of FPM config php_value settings in .user.ini was fixed in... PHP 7.2: https://bugs.php.net/bug.php?id=75212

Also, that behavior where a later declaration does not override a newer one is probably a bug: php/php-src#13249

We now use php-fpm -tt to dump the config, since that will have stuff printed in evaluation order - if the bug above ever gets fixed, we have to do nothing.

This also removes the need for us to handle the PHP-FPM config include directives ourselves, and as a result, variable expansion and globbing now work in these!

GUS-W-14901875
robinwo pushed a commit to robinwo/heroku-buildpack-php that referenced this issue Sep 13, 2024
Turns out that bug which would not allow overriding of FPM config php_value settings in .user.ini was fixed in... PHP 7.2: https://bugs.php.net/bug.php?id=75212

Also, that behavior where a later declaration does not override a newer one is probably a bug: php/php-src#13249

We now use php-fpm -tt to dump the config, since that will have stuff printed in evaluation order - if the bug above ever gets fixed, we have to do nothing.

This also removes the need for us to handle the PHP-FPM config include directives ourselves, and as a result, variable expansion and globbing now work in these!

GUS-W-14901875
robinwo pushed a commit to robinwo/heroku-buildpack-php that referenced this issue Sep 13, 2024
Turns out that bug which would not allow overriding of FPM config php_value settings in .user.ini was fixed in... PHP 7.2: https://bugs.php.net/bug.php?id=75212

Also, that behavior where a later declaration does not override a newer one is probably a bug: php/php-src#13249

We now use php-fpm -tt to dump the config, since that will have stuff printed in evaluation order - if the bug above ever gets fixed, we have to do nothing.

This also removes the need for us to handle the PHP-FPM config include directives ourselves, and as a result, variable expansion and globbing now work in these!

GUS-W-14901875
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants