Skip to content

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

Closed
bix0r wants to merge 2 commits into
php:PHP-8.1from
bix0r:issue-8699-ini-get-opcache-optimization-8.1
Closed

bix0r wants to merge 2 commits into
php:PHP-8.1from
bix0r:issue-8699-ini-get-opcache-optimization-8.1

Conversation

@bix0r

@bix0r bix0r commented Jul 13, 2022

Copy link
Copy Markdown

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

bukka commented Aug 28, 2022

Copy link
Copy Markdown
Member

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?

@dstogov dstogov left a comment

Copy link
Copy Markdown
Member

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

bukka commented Aug 29, 2022

Copy link
Copy Markdown
Member

@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

bukka commented Aug 29, 2022 •

Copy link
Copy Markdown
Member

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

dstogov commented Aug 29, 2022

Copy link
Copy Markdown
Member

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

bukka commented Aug 29, 2022

Copy link
Copy Markdown
Member

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.

@krakjoe

krakjoe commented Aug 31, 2025

Copy link
Copy Markdown
Member

Closing this, as we settled on a different solution that doesn't require we drop the optimization.

Assigning to you @bukka for the sake of your own book-keeping, and in-case you ever get around to ZEND_INI_ADMIN.

@krakjoe krakjoe closed this Aug 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants