From 7c1e4610323e5d4219d5a8035bcac0e663323c6a Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Fri, 25 Jul 2025 13:22:03 +0200 Subject: [PATCH 1/3] Removed unused var exec_time and fetch time in opcache/zend_accelerator_module.c (GH-19235) --- ext/opcache/zend_accelerator_module.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index 56f9178ef0fca..1db7160bc889d 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -599,8 +599,6 @@ static int accelerator_get_scripts(zval *return_value) zval persistent_script_report; zend_accel_hash_entry *cache_entry; struct tm *ta; - struct timeval exec_time; - struct timeval fetch_time; if (!ZCG(accelerator_enabled) || accelerator_shm_read_lock() != SUCCESS) { return 0; @@ -630,8 +628,6 @@ static int accelerator_get_scripts(zval *return_value) if (ZCG(accel_directives).validate_timestamps) { add_assoc_long(&persistent_script_report, "timestamp", (zend_long)script->timestamp); } - timerclear(&exec_time); - timerclear(&fetch_time); add_assoc_long(&persistent_script_report, "revalidate", (zend_long)script->dynamic_members.revalidate); From b428bc934a2deeb455ce34688d29ff729768458d Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Fri, 25 Jul 2025 09:04:28 -0700 Subject: [PATCH 2/3] ext/reflection: voidify `format_default_value()` (#19234) This function always returned SUCCESS unconditionally; removing the return type revealed some impossible code for handling FAILURE that could also be removed. --- ext/reflection/php_reflection.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 94f8129978638..3a37304dc2dc5 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -716,7 +716,7 @@ static zval *get_default_from_recv(zend_op_array *op_array, uint32_t offset) { return RT_CONSTANT(recv, recv->op2); } -static int format_default_value(smart_str *str, zval *value) { +static void format_default_value(smart_str *str, zval *value) { if (smart_str_append_zval(str, value, SIZE_MAX) == SUCCESS) { /* Nothing to do. */ } else if (Z_TYPE_P(value) == IS_ARRAY) { @@ -761,7 +761,6 @@ static int format_default_value(smart_str *str, zval *value) { smart_str_append(str, ast_str); zend_string_release(ast_str); } - return SUCCESS; } static inline bool has_internal_arg_info(const zend_function *fptr) { @@ -808,9 +807,7 @@ static void _parameter_string(smart_str *str, zend_function *fptr, struct _zend_ zval *default_value = get_default_from_recv((zend_op_array*)fptr, offset); if (default_value) { smart_str_appends(str, " = "); - if (format_default_value(str, default_value) == FAILURE) { - return; - } + format_default_value(str, default_value); } } } @@ -1055,9 +1052,7 @@ static void _property_string(smart_str *str, zend_property_info *prop, const cha zval *default_value = property_get_default(prop); if (default_value && !Z_ISUNDEF_P(default_value)) { smart_str_appends(str, " = "); - if (format_default_value(str, default_value) == FAILURE) { - return; - } + format_default_value(str, default_value); } } @@ -7181,10 +7176,7 @@ ZEND_METHOD(ReflectionAttribute, __toString) smart_str_appends(&str, " = "); } - if (format_default_value(&str, &attr->data->args[i].value) == FAILURE) { - smart_str_free(&str); - RETURN_THROWS(); - } + format_default_value(&str, &attr->data->args[i].value); smart_str_appends(&str, " ]\n"); } From a2d8ee27f2b7fba8297c0573392f3e9ec86d509c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 25 Jul 2025 18:36:47 +0200 Subject: [PATCH 3/3] opcache: Disallow changing `opcache.memory_consumption` when SHM is set up (#19146) * opcache: Reset `accel_startup_ok` after shutting down This is necessary for phpdbg, which runs multiple startup/shutdown cycles in the same process. * 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. --- NEWS | 4 ++++ UPGRADING | 3 +++ ext/opcache/ZendAccelerator.c | 2 ++ ext/opcache/zend_accelerator_module.c | 9 +++++++++ 4 files changed, 18 insertions(+) diff --git a/NEWS b/NEWS index 961870b6f3053..1c7efd83bba06 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,10 @@ PHP NEWS . Add support for CURLINFO_CONN_ID in curl_getinfo() (thecaliskan) . Add support for CURLINFO_QUEUE_TIME_T in curl_getinfo() (thecaliskan) +- OPcache: + . Disallow changing opcache.memory_consumption when SHM is already set up. + (timwolla) + - OpenSSL: . Add $digest_algo parameter to openssl_public_encrypt() and openssl_private_decrypt() functions. (Jakub Zelenka) diff --git a/UPGRADING b/UPGRADING index 5a206fee6d115..68b3e34390d0e 100644 --- a/UPGRADING +++ b/UPGRADING @@ -607,6 +607,9 @@ PHP 8.5 UPGRADE NOTES . The default value of opcache.jit_hot_loop is now 61 (a prime) to prevent it from being a multiple of loop iteration counts. It is recommended that this parameter is set to a prime number. + . Changing opcache.memory_consumption when OPcache SHM is already set up + will now correctly report a failure instead of silently doing nothing and + showing misleading values in PHPInfo. - OpenSSL: Added openssl.libctx to select the OpenSSL library context type. Either diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 0f1f1c986985b..dd063c67e1546 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -3509,6 +3509,8 @@ void accel_shutdown(void) if ((ini_entry = zend_hash_str_find_ptr(EG(ini_directives), "include_path", sizeof("include_path")-1)) != NULL) { ini_entry->on_modify = orig_include_path_on_modify; } + + accel_startup_ok = false; } void zend_accel_schedule_restart(zend_accel_restart_reason reason) diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index 1db7160bc889d..4c103d6e061cc 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -77,6 +77,15 @@ static int validate_api_restriction(void) static ZEND_INI_MH(OnUpdateMemoryConsumption) { + if (accel_startup_ok) { + if (strcmp(sapi_module.name, "fpm-fcgi") == 0) { + 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"); + } else { + zend_accel_error(ACCEL_LOG_WARNING, "opcache.memory_consumption cannot be changed when OPcache is already set up.\n"); + } + return FAILURE; + } + zend_long *p = (zend_long *) ZEND_INI_GET_ADDR(); zend_long memsize = atoi(ZSTR_VAL(new_value)); /* sanity check we must use at least 8 MB */