Skip to content

Conversation

TimWolla
Copy link
Member

Normally changing the INI value is not possible after SHM is set up, since it is PHP_INI_SYSTEM. FPM is a notable exception: SHM is set up in the master process, but when spawning the individual pools, the php_admin_value config option can be used to change PHP_INI_SYSTEM INIs on a per-pool basis. This does not work for this option, since it will only be read on early start, leading to misleading PHPInfo output, since the INI value appears to be successfully set and since some of the calculated values are derived from the INI value rather than the actual value.

TimWolla added 2 commits July 16, 2025 10:28
This is necessary for phpdbg, which runs multiple startup/shutdown cycles in
the same process.
…et up

Normally changing the INI value is not possible after SHM is set up, since it
is `PHP_INI_SYSTEM`. FPM is a notable exception: SHM is set up in the master
process, but when spawning the individual pools, the `php_admin_value` config
option can be used to change `PHP_INI_SYSTEM` INIs on a per-pool basis. This
does not work for this option, since it will only be read on early start,
leading to misleading PHPInfo output, since the INI value appears to be
successfully set and since some of the calculated values are derived from the
INI value rather than the actual value.
@TimWolla TimWolla force-pushed the opcache-memory-after-shm-setup branch from d7dbe47 to 3265c7c Compare July 16, 2025 08:28
@TimWolla TimWolla requested a review from arnaud-lb July 16, 2025 08:29
Copy link
Member

@arnaud-lb arnaud-lb left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@TimWolla TimWolla merged commit a2d8ee2 into php:master Jul 25, 2025
9 checks passed
@TimWolla TimWolla deleted the opcache-memory-after-shm-setup branch July 25, 2025 16:36
TimWolla added a commit to TimWolla/php-src that referenced this pull request Aug 28, 2025
The error message will now advice on the `php_admin_value[opcache.enable]=1`
mistake. It will also send the message to OPcache’s logging facility instead of
the regular error handling logic during startup so that it will not be made
available to `error_get_last()`, since it is related to a specific request and
thus not actionable by a script either.

php#19146 made a related change to `opcache.memory_consumption`.
TimWolla added a commit that referenced this pull request Aug 30, 2025
…19619)

* opcache: Do not emit “temporary enabling” message when OPcache is already active

An easy way to accidentally enable OPcache “temporarily” is by using
`php_admin_value[opcache.enable]=1` within a FPM pool’s configuration, since
the `php_admin_value` settings mostly behave like settings in php.ini, with
many OPcache INI settings being a notable exception.

As long as OPcache is already enabled within php.ini (or simply by default),
emitting a warning for `php_admin_value[opcache.enable]=1` or similar is going
to be confusing, since is not actually temporarily enabling anything.

A follow-up commit will also try to detect this kind of incorrect configuration
and try to provide better advice for cases where OPcache is actually not yet
enabled.

* opcache: Improve error message when OPcache is enabled dynamically

The error message will now advice on the `php_admin_value[opcache.enable]=1`
mistake. It will also send the message to OPcache’s logging facility instead of
the regular error handling logic during startup so that it will not be made
available to `error_get_last()`, since it is related to a specific request and
thus not actionable by a script either.

#19146 made a related change to `opcache.memory_consumption`.

* opcache: Fix typo in warning message

* opcache: Use more formal language in warning message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants