Commit 51d3a882be4 for php

commit 51d3a882be4288f509f763bb6740a76c810da854
Author: Jack Worman <66142217+jack-worman@users.noreply.github.com>
Date:   Tue Nov 3 12:03:27 2026 -0600

    Improve opcache.max_accelerated_files validation (#22412)

    * Improve opcache.max_accelerated_files validation

diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml
index dcd61adf17c..a02097f0329 100644
--- a/.github/workflows/test-suite.yml
+++ b/.github/workflows/test-suite.yml
@@ -480,7 +480,7 @@ jobs:
           echo opcache.memory_consumption=256M >> /etc/php.d/opcache.ini
           echo opcache.file_update_protection=0 >> /etc/php.d/opcache.ini
           echo opcache.interned_strings_buffer=64 >> /etc/php.d/opcache.ini
-          echo opcache.max_accelerated_files=100000 >> /etc/php.d/opcache.ini
+          echo opcache.max_accelerated_files=130987 >> /etc/php.d/opcache.ini
       - name: Enable JIT
         if: ${{ matrix.type != 'verify_type_inference' }}
         run: |
diff --git a/UPGRADING b/UPGRADING
index 9804b8706b8..dbfa42b9b17 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -153,6 +153,12 @@ PHP 8.7 UPGRADE NOTES
 11. Changes to INI File Handling
 ========================================

+- Opcache:
+  . opcache.max_accelerated_files now defaults to 16229 (previously 10000),
+    accepts values up to 1048793 (previously 1000000), and logs a warning for
+    values other than 223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407,
+    130987, 262237, 524521 and 1048793.
+
 ========================================
 12. Windows Support
 ========================================
diff --git a/ext/opcache/tests/bug79665.phpt b/ext/opcache/tests/bug79665.phpt
index 7e101f5a008..64b7d30d02b 100644
--- a/ext/opcache/tests/bug79665.phpt
+++ b/ext/opcache/tests/bug79665.phpt
@@ -28,5 +28,5 @@
 float(0.05)
 string(3) "128"
 int(134217728)
-string(5) "10000"
-int(10000)
+string(5) "16229"
+int(16229)
diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c
index aa8826e69f1..5aff69886c1 100644
--- a/ext/opcache/zend_accelerator_module.c
+++ b/ext/opcache/zend_accelerator_module.c
@@ -41,7 +41,7 @@

 #define STRING_NOT_NULL(s) (NULL == (s)?"":s)
 #define MIN_ACCEL_FILES 200
-#define MAX_ACCEL_FILES 1000000
+#define MAX_ACCEL_FILES 1048793
 /* Max value of opcache.interned_strings_buffer */
 #define MAX_INTERNED_STRINGS_BUFFER_SIZE ((zend_long)MIN( \
 	MIN( \
@@ -146,6 +146,23 @@ static ZEND_INI_MH(OnUpdateMaxAcceleratedFiles)
 		zend_accel_error(ACCEL_LOG_WARNING, "opcache.max_accelerated_files is set above the limit (%d).\n", MAX_ACCEL_FILES);
 		return FAILURE;
 	}
+	if (
+		size != 223
+		&& size != 463
+		&& size != 983
+		&& size != 1979
+		&& size != 3907
+		&& size != 7963
+		&& size != 16229
+		&& size != 32531
+		&& size != 65407
+		&& size != 130987
+		&& size != 262237
+		&& size != 524521
+		&& size != 1048793
+	) {
+		zend_accel_error(ACCEL_LOG_WARNING, "opcache.max_accelerated_files should be a value in {223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407, 130987, 262237, 524521, 1048793}.\n");
+	}
 	*p = size;
 	return SUCCESS;
 }
@@ -307,7 +324,7 @@ ZEND_INI_BEGIN()
 	STD_PHP_INI_ENTRY("opcache.log_verbosity_level"   , "1"   , PHP_INI_SYSTEM, OnUpdateLong, accel_directives.log_verbosity_level,       zend_accel_globals, accel_globals)
 	STD_PHP_INI_ENTRY("opcache.memory_consumption"    , "128"  , PHP_INI_SYSTEM, OnUpdateMemoryConsumption,    accel_directives.memory_consumption,        zend_accel_globals, accel_globals)
 	STD_PHP_INI_ENTRY("opcache.interned_strings_buffer", "8"  , PHP_INI_SYSTEM, OnUpdateInternedStringsBuffer,	 accel_directives.interned_strings_buffer,   zend_accel_globals, accel_globals)
-	STD_PHP_INI_ENTRY("opcache.max_accelerated_files" , "10000", PHP_INI_SYSTEM, OnUpdateMaxAcceleratedFiles,	 accel_directives.max_accelerated_files,     zend_accel_globals, accel_globals)
+	STD_PHP_INI_ENTRY("opcache.max_accelerated_files" , "16229", PHP_INI_SYSTEM, OnUpdateMaxAcceleratedFiles,	 accel_directives.max_accelerated_files,     zend_accel_globals, accel_globals)
 	STD_PHP_INI_ENTRY("opcache.max_wasted_percentage" , "5"   , PHP_INI_SYSTEM, OnUpdateMaxWastedPercentage,	 accel_directives.max_wasted_percentage,     zend_accel_globals, accel_globals)
 	STD_PHP_INI_ENTRY("opcache.force_restart_timeout" , "180" , PHP_INI_SYSTEM, OnUpdateLong,	             accel_directives.force_restart_timeout,     zend_accel_globals, accel_globals)
 	STD_PHP_INI_ENTRY("opcache.revalidate_freq"       , "2"   , PHP_INI_ALL   , OnUpdateLong,	             accel_directives.revalidate_freq,           zend_accel_globals, accel_globals)
diff --git a/ext/phar/tests/024-opcache-win32.phpt b/ext/phar/tests/024-opcache-win32.phpt
index a136a7c2a9b..3746ce1b240 100644
--- a/ext/phar/tests/024-opcache-win32.phpt
+++ b/ext/phar/tests/024-opcache-win32.phpt
@@ -16,7 +16,7 @@
 opcache.file_cache={PWD}/024-file_cache
 opcache.memory_consumption=64
 opcache.interned_strings_buffer=8
-opcache.max_accelerated_files=4000
+opcache.max_accelerated_files=7963
 opcache.jit=tracing
 opcache.revalidate_freq=60
 opcache.fast_shutdown=1
diff --git a/php.ini-development b/php.ini-development
index 8663f1c21de..1b08755b329 100644
--- a/php.ini-development
+++ b/php.ini-development
@@ -1684,8 +1684,8 @@ ldap.max_links = -1
 ;opcache.interned_strings_buffer=8

 ; The maximum number of keys (scripts) in the OPcache hash table.
-; Only numbers between 200 and 1000000 are allowed.
-;opcache.max_accelerated_files=10000
+; Only numbers in {223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407, 130987, 262237, 524521, 1048793} are allowed.
+;opcache.max_accelerated_files=16229

 ; The maximum percentage of "wasted" memory until a restart is scheduled.
 ;opcache.max_wasted_percentage=5
diff --git a/php.ini-production b/php.ini-production
index 497a3774b8e..b4332904b09 100644
--- a/php.ini-production
+++ b/php.ini-production
@@ -1686,8 +1686,8 @@ ldap.max_links = -1
 ;opcache.interned_strings_buffer=8

 ; The maximum number of keys (scripts) in the OPcache hash table.
-; Only numbers between 200 and 1000000 are allowed.
-;opcache.max_accelerated_files=10000
+; Only numbers in {223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407, 130987, 262237, 524521, 1048793} are allowed.
+;opcache.max_accelerated_files=16229

 ; The maximum percentage of "wasted" memory until a restart is scheduled.
 ;opcache.max_wasted_percentage=5