[PHP-CVS] [php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5

[email protected] (David Carlier)
Newsgroups php.cvs
Message-ID <[email protected]>
Author: David Carlier (devnexen)
Date: 2026-08-20T22:27:05+01:00

Commit: https://github.com/php/php-src/commit/9eb30eeb16c9e3f932be43eeb0ae4c8d7d2537e3
Raw diff: https://github.com/php/php-src/commit/9eb30eeb16c9e3f932be43eeb0ae4c8d7d2537e3.diff

Merge branch 'PHP-8.4' into PHP-8.5

* PHP-8.4:
  ext/opcache: opcache.interned_strings_buffer per FPM pool crashed on restart.

Changed paths:
  A  sapi/fpm/tests/gh23288-opcache-interned-strings-buffer-pool.phpt
  M  ext/opcache/ZendAccelerator.c
  M  ext/opcache/zend_accelerator_module.c


Diff:

diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index 62a33c451056..0b685c6e1fec 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -2732,7 +2732,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();
 				}
 
diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c
index 6f668af9b714..316db5bb7cbd 100644
--- a/ext/opcache/zend_accelerator_module.c
+++ b/ext/opcache/zend_accelerator_module.c
@@ -105,6 +105,15 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption)
 
 static ZEND_INI_MH(OnUpdateInternedStringsBuffer)
 {
+	if (accel_startup_ok) {
+		if (strcmp(sapi_module.name, "fpm-fcgi") == 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.\n");
+		}
+		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--
+<?php include "skipif.inc"; ?>
+--FILE--
+<?php
+
+require_once "tester.inc";
+
+$cfg = <<<EOT
+[global]
+error_log = {{FILE:LOG}}
+[unconfined]
+listen = {{ADDR}}
+pm = static
+pm.max_children = 1
+php_admin_value[opcache.interned_strings_buffer] = 8
+EOT;
+
+$code = <<<EOT
+<?php
+opcache_reset();
+opcache_reset();
+echo "ok";
+EOT;
+
+$opcache = ini_get('extension_dir') . DIRECTORY_SEPARATOR . 'opcache.' . PHP_SHLIB_SUFFIX;
+$extraArgs = is_file($opcache) ? ['-dzend_extension=' . $opcache] : [];
+
+$tester = new FPM\Tester($cfg, $code);
+$tester->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--
+<?php
+require_once "tester.inc";
+FPM\Tester::clean();
+?>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.