bug66338.phpt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. --TEST--
  2. Bug #66338 (Optimization binding of class constants is not safely opcacheable)
  3. --INI--
  4. opcache.enable=0
  5. --EXTENSIONS--
  6. opcache
  7. --CONFLICTS--
  8. server
  9. --FILE--
  10. <?php
  11. $root = str_replace('.php', "", __FILE__);
  12. $base = basename( $root );
  13. file_put_contents( "$root-Officials.inc", '<?php
  14. class Officials { static function getLeader() { return LocalTerms::GOV_LEADER; } }
  15. ' );
  16. file_put_contents( "$root-clientUS.php", '<?php
  17. class LocalTerms { const GOV_LEADER = "Barack Hussein Obama II"; }
  18. require \''.$root.'-Officials.inc\';
  19. printf( "The President of the USA is %s\n", Officials::getLeader() );
  20. ' );
  21. file_put_contents( "$root-clientUK.php", '<?php
  22. class LocalTerms { const GOV_LEADER = "David William Donald Cameron"; }
  23. require \''.$root.'-Officials.inc\';
  24. printf( "The Prime Minister of the UK is %s\n", Officials::getLeader() );
  25. ' );
  26. include "php_cli_server.inc";
  27. $uri = sprintf("http://%s/%s", PHP_CLI_SERVER_ADDRESS, basename(__FILE__));
  28. $opt = -1; # This test works if $opt = 0
  29. php_cli_server_start("-d opcache.enable=1 -d opcache.enable_cli=1 -d opcache.optimization_level=$opt -d opcache.file_update_protection=0" );
  30. echo file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS . "/$base-clientUS.php" );
  31. echo file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS . "/$base-clientUK.php" );
  32. unlink("$root-Officials.inc");
  33. unlink("$root-clientUS.php");
  34. unlink("$root-clientUK.php");
  35. ?>
  36. --EXPECT--
  37. The President of the USA is Barack Hussein Obama II
  38. The Prime Minister of the UK is David William Donald Cameron