Commit 387a3afc6b0 for php.net

commit 387a3afc6b0831ed65f66e191e9bf328466b87ed
Author: Ilija Tovilo <ilija.tovilo@me.com>
Date:   Sat Jul 25 22:48:02 2026 +0200

    Fix run-tests.php --file-cache-prime with multiple workers (GH-22886)

    * Fix run-tests.php --file-cache-prime with multiple workers

    We want to remove the directory only before running tests, rather than for every
    test. That causes races, but also defeats the purpose of priming the cache.

    * Move opcache.opt_debug_level tests

    These need to live in ext/opcache/tests to be skipped by run-tests.php for the
    --file-cache-use tests, which won't compile the files and thus won't dump the
    output.

    * Mark preloading test as opcache.file_cache_only=0

    Preloading requires shm.

diff --git a/Zend/tests/partial_application/preloading.phpt b/Zend/tests/partial_application/preloading.phpt
index 23ad6edf2c4..ccbbf229081 100644
--- a/Zend/tests/partial_application/preloading.phpt
+++ b/Zend/tests/partial_application/preloading.phpt
@@ -4,6 +4,7 @@
 opcache.enable=1
 opcache.enable_cli=1
 opcache.preload={PWD}/preloading.inc
+opcache.file_cache_only=0
 --SKIPIF--
 <?php
 if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
diff --git a/ext/standard/tests/array/array_map_foreach_optimization_006.phpt b/ext/opcache/tests/array_map_foreach_optimization_007.phpt
similarity index 100%
rename from ext/standard/tests/array/array_map_foreach_optimization_006.phpt
rename to ext/opcache/tests/array_map_foreach_optimization_007.phpt
diff --git a/ext/standard/tests/array/array_map_foreach_optimization_007.phpt b/ext/opcache/tests/array_map_foreach_optimization_008.phpt
similarity index 100%
rename from ext/standard/tests/array/array_map_foreach_optimization_007.phpt
rename to ext/opcache/tests/array_map_foreach_optimization_008.phpt
diff --git a/run-tests.php b/run-tests.php
index 1d8be660388..998e7e24c33 100755
--- a/run-tests.php
+++ b/run-tests.php
@@ -700,6 +700,12 @@ function main(): void
     verify_config($php);
     write_information($user_tests, $phpdbg);

+    if ($file_cache === 'prime') {
+        $cache_dir = get_file_cache_dir();
+        rmdir_recursive($cache_dir);
+        mkdir($cache_dir, recursive: true);
+    }
+
     if ($test_cnt) {
         $exts_tested = [];
         $exts_skipped = [];
@@ -1054,6 +1060,11 @@ function find_files(string $dir, bool $is_ext_dir = false, bool $ignore = false)
     closedir($o);
 }

+function get_file_cache_dir(): string
+{
+    return sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'php-run-tests-file-cache';
+}
+
 function rmdir_recursive($dir)
 {
     if (!file_exists($dir)) {
@@ -2091,11 +2102,7 @@ function run_test(string $php, $file, array $env): string
     $orig_ini_settings = settings2params($ini_settings);

     if ($file_cache !== null) {
-        $ini_settings['opcache.file_cache'] = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'php-run-tests-file-cache';
-        if ($file_cache === 'prime') {
-            rmdir_recursive($ini_settings['opcache.file_cache']);
-            mkdir($ini_settings['opcache.file_cache'], recursive: true);
-        }
+        $ini_settings['opcache.file_cache'] = get_file_cache_dir();
         // Make sure warnings still show up on the second run.
         $ini_settings['opcache.record_warnings'] = '1';
         // File cache is currently incompatible with JIT.