revalidate_path_01.phpt 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. --EXTENSIONS--
  8. opcache
  9. --CONFLICTS--
  10. server
  11. --FILE--
  12. <?php
  13. $dir = __DIR__;
  14. $dir1 = "$dir/test1";
  15. $dir2 = "$dir/test2";
  16. $link = "$dir/test";
  17. $file1 = "$dir1/index.php";
  18. $file2 = "$dir2/index.php";
  19. $main = "$dir/main.php";
  20. @mkdir($dir1);
  21. @mkdir($dir2);
  22. @file_put_contents($main, '<?php include(\'' . $link .'/index.php\');');
  23. @file_put_contents($file1, "TEST 1\n");
  24. @file_put_contents($file2, "TEST 2\n");
  25. while (filemtime($file1) != filemtime($file2)) {
  26. touch($file1);
  27. touch($file2);
  28. }
  29. if (substr(PHP_OS, 0, 3) == 'WIN') {
  30. @rmdir($link);
  31. $ln = str_replace('/', '\\', $link);
  32. $d1 = realpath($dir1);
  33. `mklink /j $ln $d1`;
  34. } else {
  35. @unlink($link);
  36. @symlink($dir1, $link);
  37. }
  38. include "php_cli_server.inc";
  39. //php_cli_server_start('-d opcache.enable=1 -d opcache.enable_cli=1 -d opcache.revalidate_path=1');
  40. 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');
  41. echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/main.php');
  42. echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/main.php');
  43. if (substr(PHP_OS, 0, 3) == 'WIN') {
  44. @rmdir($link);
  45. $ln = str_replace('/', '\\', $link);
  46. $d2 = realpath($dir2);
  47. `mklink /j $ln $d2`;
  48. } else {
  49. @unlink($link);
  50. @symlink($dir2, $link);
  51. }
  52. echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/main.php');
  53. echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/main.php');
  54. ?>
  55. --CLEAN--
  56. <?php
  57. $dir = __DIR__;
  58. $dir1 = "$dir/test1";
  59. $dir2 = "$dir/test2";
  60. $link = "$dir/test";
  61. $file1 = "$dir1/index.php";
  62. $file2 = "$dir2/index.php";
  63. $main = "$dir/main.php";
  64. @unlink($main);
  65. if (substr(PHP_OS, 0, 3) == 'WIN') {
  66. @rmdir($link);
  67. } else {
  68. @unlink($link);
  69. }
  70. @unlink($file1);
  71. @unlink($file2);
  72. @rmdir($dir1);
  73. @rmdir($dir2);
  74. ?>
  75. --EXPECT--
  76. TEST 1
  77. TEST 1
  78. TEST 2
  79. TEST 2