|
| 1 | +--TEST-- |
| 2 | +Bug #66338 (Optimization binding of class constants is not safely opcacheable) |
| 3 | +--INI-- |
| 4 | +opcache.enable=0 |
| 5 | +--SKIPIF-- |
| 6 | +<?php if (!extension_loaded('Zend OPcache') || php_sapi_name() != "cli") die("skip CLI only"); ?> |
| 7 | +--FILE-- |
| 8 | +<?php |
| 9 | +$root = str_replace('.php', "", __FILE__); |
| 10 | +$base = basename( $root ); |
| 11 | + |
| 12 | +file_put_contents( "$root-Officials.inc", '<?php |
| 13 | + class Officials { static function getLeader() { return LocalTerms::GOV_LEADER; } } |
| 14 | + ' ); |
| 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 | + |
| 22 | +file_put_contents( "$root-clientUK.php", '<?php |
| 23 | + class LocalTerms { const GOV_LEADER = "David William Donald Cameron"; } |
| 24 | + require "'.$root.'-Officials.inc"; |
| 25 | + printf( "The Prime Minister of the UK is %s\n", Officials::getLeader() ); |
| 26 | + ' ); |
| 27 | + |
| 28 | +include "php_cli_server.inc"; |
| 29 | +$uri = sprintf("http://%s/%s", PHP_CLI_SERVER_ADDRESS, basename(__FILE__)); |
| 30 | +$opt = -1; # This test works if $opt = 0 |
| 31 | +php_cli_server_start("-d opcache.enable=1 -d opcache.enable_cli=1 -d opcache.optimization_level=$opt -d opcache.file_update_protection=0" ); |
| 32 | + |
| 33 | +echo file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS . "/$base-clientUS.php" ); |
| 34 | +echo file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS . "/$base-clientUK.php" ); |
| 35 | + |
| 36 | +unlink("$root-Officials.inc"); |
| 37 | +unlink("$root-clientUS.php"); |
| 38 | +unlink("$root-clientUK.php"); |
| 39 | +?> |
| 40 | +--EXPECT-- |
| 41 | +The President of the USA is Barack Hussein Obama II |
| 42 | +The Prime Minister of the UK is David William Donald Cameron |
0 commit comments