Skip to content

Commit d7dbe47

Browse files
committed
opcache: Disallow changing opcache.memory_consumption when SHM is set 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.
1 parent 02b9455 commit d7dbe47

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 8.5.0alpha3
44

5+
- OPcache:
6+
. Disallow changing opcache.memory_consumption when SHM is already set up.
7+
(timwolla)
8+
59
- Sockets:
610
. socket_set_option for multicast context throws a ValueError
711
when the socket family is not of AF_INET/AF_INET6 family. (David Carlier)

UPGRADING

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,9 @@ PHP 8.5 UPGRADE NOTES
571571
. The default value of opcache.jit_hot_loop is now 61 (a prime) to prevent it
572572
from being a multiple of loop iteration counts.
573573
It is recommended that this parameter is set to a prime number.
574+
. Changing opcache.memory_consumption when OPcache SHM is already set up
575+
will now correctly report a failure instead of silently doing nothing and
576+
showing misleading values in PHPInfo.
574577

575578
- OpenSSL:
576579
Added openssl.libctx to select the OpenSSL library context type. Either

ext/opcache/zend_accelerator_module.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ static int validate_api_restriction(void)
7676

7777
static ZEND_INI_MH(OnUpdateMemoryConsumption)
7878
{
79+
if (accel_startup_ok) {
80+
if (strcmp(sapi_module.name, "fpm-fcgi") == 0) {
81+
zend_accel_error(ACCEL_LOG_WARNING, "opcache.memory_consumption cannot be changed when OPcache is already set up. Are you using php_admin_value[opcache.memory_consumption] in an individual pool's configuration?\n");
82+
} else {
83+
zend_accel_error(ACCEL_LOG_WARNING, "opcache.memory_consumption cannot be changed when OPcache is already set up.\n");
84+
}
85+
return FAILURE;
86+
}
87+
7988
zend_long *p = (zend_long *) ZEND_INI_GET_ADDR();
8089
zend_long memsize = atoi(ZSTR_VAL(new_value));
8190
/* sanity check we must use at least 8 MB */

0 commit comments

Comments
 (0)