11--TEST--
22GH-17770: opcache.file_cache writes with JIT enabled
3+ --SKIPIF--
4+ <?php
5+ @mkdir (__DIR__ . '/gh17770_cache ' , 0777 , true );
6+ if (ini_get ('opcache.jit ' ) === false ) {
7+ die ('skip JIT is not supported ' );
8+ }
9+ ?>
310--EXTENSIONS--
411opcache
512--INI--
613opcache.enable=1
714opcache.enable_cli=1
815opcache.jit=tracing
916opcache.jit_buffer_size=16M
10- opcache.file_cache={TMP}/gh17770-opcache-file-cache
17+ opcache.file_cache="{PWD}/gh17770_cache"
1118opcache.file_cache_consistency_checks=0
12- --SKIPIF--
13- <?php
14- if (!@mkdir (sys_get_temp_dir () . '/gh17770-opcache-file-cache ' , 0777 , true ) && !is_dir (sys_get_temp_dir () . '/gh17770-opcache-file-cache ' )) {
15- die ('skip unable to create file cache directory ' );
16- }
17- if (ini_get ('opcache.jit ' ) === false ) {
18- die ('skip JIT is not supported ' );
19- }
20- ?>
2119--FILE--
2220<?php
2321function removeDirRecursive (string $ dir ): void {
@@ -45,22 +43,13 @@ $cacheDir = ini_get('opcache.file_cache');
4543removeDirRecursive ($ cacheDir );
4644@mkdir ($ cacheDir , 0777 , true );
4745
48- $ tmpPhpFile = dirname ( $ cacheDir ) . '/gh17770-opcache-target.php ' ;
46+ $ tmpPhpFile = __DIR__ . '/gh17770-opcache-target.php ' ;
4947file_put_contents ($ tmpPhpFile , "<?php \nfunction gh17770() { return 42; } \ngh17770(); \n" );
5048
5149@opcache_reset ();
5250opcache_compile_file ($ tmpPhpFile );
5351
54- $ hasCacheFile = false ;
55- $ iterator = new RecursiveIteratorIterator (
56- new RecursiveDirectoryIterator ($ cacheDir , RecursiveDirectoryIterator::SKIP_DOTS )
57- );
58- foreach ($ iterator as $ entry ) {
59- if ($ entry ->isFile ()) {
60- $ hasCacheFile = true ;
61- break ;
62- }
63- }
52+ $ hasCacheFile = opcache_is_script_cached_in_file_cache ($ tmpPhpFile );
6453
6554echo $ hasCacheFile ? "OK \n" : "FAIL: opcache file cache is empty \n" ;
6655?>
@@ -87,9 +76,8 @@ function removeDirRecursive(string $dir): void {
8776 @rmdir ($ dir );
8877}
8978
90- $ cacheDir = ini_get ('opcache.file_cache ' );
91- removeDirRecursive ($ cacheDir );
92- @unlink (dirname ($ cacheDir ) . '/gh17770-opcache-target.php ' );
79+ removeDirRecursive (__DIR__ . '/gh17770_cache ' );
80+ @unlink (__DIR__ . '/gh17770-opcache-target.php ' );
9381?>
9482--EXPECT--
9583OK
0 commit comments