revalidate_path_01.phpt 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. --TEST--
  2. revalidate_path 01: OPCache must cache only resolved real paths when revalidate_path is set
  3. --INI--
  4. opcache.enable=1
  5. opcache.enable_cli=1
  6. opcache.revalidate_path=1
  7. --SKIPIF--
  8. <?php require_once('skipif.inc'); ?>
  9. <?php if (php_sapi_name() != "cli") die("skip CLI only"); ?>
  10. --FILE--
  11. <?php
  12. $dir = dirname(__FILE__);
  13. $dir1 = "$dir/test1";
  14. $dir2 = "$dir/test2";
  15. $link = "$dir/test";
  16. $file1 = "$dir1/index.php";
  17. $file2 = "$dir2/index.php";
  18. $main = "$dir/main.php";
  19. @mkdir($dir1);
  20. @mkdir($dir2);
  21. @file_put_contents($main, '<?php include(\'' . $link .'/index.php\');');
  22. @file_put_contents($file1, "TEST 1\n");
  23. @file_put_contents($file2, "TEST 2\n");
  24. while (filemtime($file1) != filemtime($file2)) {
  25. touch($file1);
  26. touch($file2);
  27. }
  28. if (substr(PHP_OS, 0, 3) == 'WIN') {
  29. @rmdir($link);
  30. $ln = str_replace('/', '\\', $link);
  31. $d1 = realpath($dir1);
  32. `mklink /j $ln $d1`;
  33. } else {
  34. @unlink($link);
  35. @symlink($dir1, $link);
  36. }
  37. include "php_cli_server.inc";
  38. //php_cli_server_start('-d opcache.enable=1 -d opcache.enable_cli=1 -d opcache.revalidate_path=1');
  39. php_cli_server_start('-d opcache.enable=1 -d opcache.enable_cli=1 -d opcache.revalidate_path=1 -d opcache.file_update_protection=0 -d realpath_cache_size=0');
  40. echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/main.php');
  41. echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/main.php');
  42. if (substr(PHP_OS, 0, 3) == 'WIN') {
  43. @rmdir($link);
  44. $ln = str_replace('/', '\\', $link);
  45. $d2 = realpath($dir2);
  46. `mklink /j $ln $d2`;
  47. } else {
  48. @unlink($link);
  49. @symlink($dir2, $link);
  50. }
  51. echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/main.php');
  52. echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/main.php');
  53. ?>
  54. --CLEAN--
  55. <?php
  56. $dir = dirname(__FILE__);
  57. $dir1 = "$dir/test1";
  58. $dir2 = "$dir/test2";
  59. $link = "$dir/test";
  60. $file1 = "$dir1/index.php";
  61. $file2 = "$dir2/index.php";
  62. $main = "$dir/main.php";
  63. @unlink($main);
  64. if (substr(PHP_OS, 0, 3) == 'WIN') {
  65. @rmdir($link);
  66. } else {
  67. @unlink($link);
  68. }
  69. @unlink($file1);
  70. @unlink($file2);
  71. @rmdir($dir1);
  72. @rmdir($dir2);
  73. ?>
  74. --EXPECT--
  75. TEST 1
  76. TEST 1
  77. TEST 2
  78. TEST 2