Skip to content

Fix GH-8699: ini_get() opcache optimization in 8.1 #8997

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
wants to merge 2 commits into
base: PHP-8.1
Choose a base branch
from

Conversation

bix0r
Copy link

@bix0r bix0r commented Jul 13, 2022

This fixes #8699 for PHP-8.1.
Can also be used for 8.0 and 7.4.

For 8.2, the problematic code has been moved to zend_optimizer.c.

bix0r added 2 commits July 13, 2022 13:27
We only need to test this in cli, but this is a problem in ALL sapis that allow
opcache optimizations.

Issue: phpGH-8699
When using opcache with optimization return value from ini_get() for
PHP_INI_SYSTEM type directives was cached per file.
This is a problem for shared files that use ini_get().
This is a real problem for virtual hosts (both apache and fpm) because using
php_admin_(value|flag) sets any value as PHP_INI_SYSTEM, and this really is the
only way to set specific values per virtual host.
Like changing the upload directory.

Fixes phpGH-8699
@bukka
Copy link
Member

bukka commented Aug 28, 2022

I think it makes sense from the FPM PoV not to do this optimization because it can be changed using PHP_ADMIN_VALUE. @dstogov are you fine with this change?

Copy link
Member

@dstogov dstogov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is a bug and if it should be fixed.

By design, ZEND_INI_SYSTEM setting are set once during PHP startup and cannot be changed. Settings that may be changed per-request should be ZEND_INI_PERDIR. FPM ignores this, but this doesn't mean overriding of all ZEND_INI_SYSTEM will work.

@bukka
Copy link
Member

bukka commented Aug 29, 2022

@dstogov You are right in principle. However PHP_ADMIN_VALUE is a bit special use case as it allows controlling ini settings from the server which is often used for the whole pool in the same way like defining the ini in the config. It actually works in a way that as soon as it is sent, then it impact all requests in the pool even if it is sent just once. Not sure if that's the right thing to do but that's how it currently works. Anyway it is still useful to allow changing any settings in this way. As you can see in the bug report, it's a perfectly valid use case and for many users this optimizations is not really worth loosing that functionality. Do you see actually some visible impact of this optimization? If so, maybe we could make the optimization optional?

@bukka
Copy link
Member

bukka commented Aug 29, 2022

That said I would agree that it's not exactly a bug and I'd rather not change in the patch release. This slightly protects people that expose FPM to public network as we had bunch of reports about allowing anyone to set PHP_ADMIN_VALUE. I know it is a terrible idea but people do that sometimes unknowingly and this might actually protect them a little bit. So we should at least introduce optional disabling of PHP_ADMIN_VALUE in FPM before removing this optimization.

@dstogov
Copy link
Member

dstogov commented Aug 29, 2022

The proper solution would be adding ZEND_INI_PERDIR or some new (e.g.ZEND_INI_ADMIN) to ini settings that might be modified through PHP_ADMIN_VALUE.

@bukka
Copy link
Member

bukka commented Aug 29, 2022

Ok I think introducing new ZEND_INI_ADMIN is probably the way to go as it is a bit more special and we can careful pick all the supported options specifically for this use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants