|
| 1 | +--TEST-- |
| 2 | +Phar: phar:// include with Opcache |
| 3 | +--SKIPIF-- |
| 4 | +<?php if (strpos(PHP_OS, 'WIN') === false) die("skip Extra warning on Windows."); ?> |
| 5 | +<?php if (!extension_loaded("phar")) die("skip"); ?> |
| 6 | +<?php if (!extension_loaded('Zend OPcache')) die('skip Zend OPcache extension not available'); ?> |
| 7 | +<?php |
| 8 | + $cache_dir = dirname(__FILE__) . "/024-file_cache"; |
| 9 | + if (!is_dir($cache_dir) && !mkdir($cache_dir)) die("skip unable to create file_cache dir"); |
| 10 | +?> |
| 11 | +--INI-- |
| 12 | +phar.require_hash=0 |
| 13 | +opcache.enable=1 |
| 14 | +opcache.enable_cli=1 |
| 15 | +opcache.file_cache={PWD}/024-file_cache |
| 16 | +opcache.memory_consumption=64 |
| 17 | +opcache.interned_strings_buffer=8 |
| 18 | +opcache.max_accelerated_files=4000 |
| 19 | +opcache.jit_buffer_size=6M |
| 20 | +opcache.revalidate_freq=60 |
| 21 | +opcache.fast_shutdown=1 |
| 22 | +--FILE-- |
| 23 | +<?php |
| 24 | + |
| 25 | +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; |
| 26 | +$pname = 'phar://' . $fname; |
| 27 | +$file = "<?php __HALT_COMPILER(); ?>"; |
| 28 | + |
| 29 | +$files = array(); |
| 30 | +$files['a.php'] = '<?php echo "This is a\n"; ?>'; |
| 31 | +$files['b.php'] = '<?php echo "This is b\n"; ?>'; |
| 32 | +$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>'; |
| 33 | + |
| 34 | +include 'files/phar_test.inc'; |
| 35 | + |
| 36 | +include $pname . '/a.php'; |
| 37 | +include $pname . '/b.php'; |
| 38 | +include $pname . '/b/c.php'; |
| 39 | + |
| 40 | +$cache_dir = ini_get("opcache.file_cache"); |
| 41 | +if (is_dir($cache_dir)) { |
| 42 | + $it = new RecursiveIteratorIterator( |
| 43 | + new RecursiveDirectoryIterator($cache_dir, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST |
| 44 | + ); |
| 45 | + foreach ($it as $fi) { |
| 46 | + $fn = ($fi->isDir() ? 'rmdir' : 'unlink'); |
| 47 | + $fn($fi->getRealPath()); |
| 48 | + } |
| 49 | + |
| 50 | + rmdir($cache_dir); |
| 51 | +} |
| 52 | + |
| 53 | +?> |
| 54 | +===DONE=== |
| 55 | +--CLEAN-- |
| 56 | +<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?> |
| 57 | +--EXPECT-- |
| 58 | +This is a |
| 59 | +This is b |
| 60 | +This is b/c |
| 61 | +===DONE=== |
0 commit comments