diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index a2d964c15070..221cc55d9f6d 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -2715,7 +2715,7 @@ ZEND_RINIT_FUNCTION(zend_accelerator) zend_reset_cache_vars(); zend_accel_hash_clean(&ZCSG(hash)); - if (ZCG(accel_directives).interned_strings_buffer) { + if (ZCSG(interned_strings).saved_top) { accel_interned_strings_restore_state(); } @@ -3444,6 +3444,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 ffa09aaf9e67..9bc15f45c4b9 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -93,6 +93,15 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption) static ZEND_INI_MH(OnUpdateInternedStringsBuffer) { + if (accel_startup_ok) { + if (strcmp(sapi_module.name, "fpm-cgi") == 0) { + zend_accel_error(ACCEL_LOG_WARNING, "opcache.interned_strings_buffer cannot be changed when OPcache is already set up. Are you using php_admin_value[opcache.interned_strings_buffer] in an individual pool's configuration?\n"); + } else { + zend_accel_error(ACCEL_LOG_WARNING, "opcache.interned_strings_buffer cannot be changed when OPcache is already set up."); + } + return FAILURE; + } + zend_long *p = (zend_long *) ZEND_INI_GET_ADDR(); zend_long size = zend_ini_parse_quantity_warn(new_value, entry->name); diff --git a/sapi/fpm/tests/gh23288-opcache-interned-strings-buffer-pool.phpt b/sapi/fpm/tests/gh23288-opcache-interned-strings-buffer-pool.phpt new file mode 100644 index 000000000000..8f48b3a8c209 --- /dev/null +++ b/sapi/fpm/tests/gh23288-opcache-interned-strings-buffer-pool.phpt @@ -0,0 +1,50 @@ +--TEST-- +FPM: GH-23288 - opcache.interned_strings_buffer overridden per pool must not crash on restart +--EXTENSIONS-- +opcache +--SKIPIF-- + +--FILE-- +start($extraArgs, iniEntries: ['opcache.interned_strings_buffer' => '0']); +$tester->expectLogStartNotices(); +$tester->request()->expectBody('ok'); +$tester->request()->expectBody('ok'); +$tester->request()->expectBody('ok'); +$tester->terminate(); +$tester->expectLogTerminatingNotices(); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- +