Skip to content

Commit 436ca2d

Browse files
committed
Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5: Fixed reavlidate_path=1 behavior to avoid caching of symlinks values. Conflicts: NEWS
2 parents beed288 + 16e95d9 commit 436ca2d

File tree

2 files changed

+65
-3
lines changed

2 files changed

+65
-3
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,8 +1157,9 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
11571157
zend_persistent_script *existing_persistent_script = (zend_persistent_script *)bucket->data;
11581158

11591159
if (!existing_persistent_script->corrupted) {
1160-
if (!ZCG(accel_directives).validate_timestamps ||
1161-
(new_persistent_script->timestamp == existing_persistent_script->timestamp)) {
1160+
if (!ZCG(accel_directives).revalidate_path &&
1161+
(!ZCG(accel_directives).validate_timestamps ||
1162+
(new_persistent_script->timestamp == existing_persistent_script->timestamp))) {
11621163
zend_accel_add_key(key, key_length, bucket TSRMLS_CC);
11631164
}
11641165
zend_shared_alloc_unlock(TSRMLS_C);
@@ -1199,7 +1200,7 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
11991200

12001201
/* store script structure in the hash table */
12011202
bucket = zend_accel_hash_update(&ZCSG(hash), new_persistent_script->full_path, new_persistent_script->full_path_len + 1, 0, new_persistent_script);
1202-
if (bucket &&
1203+
if (bucket && !ZCG(accel_directives).revalidate_path &&
12031204
/* key may contain non-persistent PHAR aliases (see issues #115 and #149) */
12041205
memcmp(key, "phar://", sizeof("phar://") - 1) != 0 &&
12051206
(new_persistent_script->full_path_len != key_length ||
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
@unlink($link);
29+
@symlink($dir1, $link);
30+
31+
include "php_cli_server.inc";
32+
//php_cli_server_start('-d opcache.enable=1 -d opcache.enable_cli=1 -d opcache.revalidate_path=1');
33+
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');
34+
echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/main.php');
35+
echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/main.php');
36+
@unlink($link);
37+
@symlink($dir2, $link);
38+
echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/main.php');
39+
echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/main.php');
40+
?>
41+
--CLEAN--
42+
<?php
43+
$dir = dirname(__FILE__);
44+
$dir1 = "$dir/test1";
45+
$dir2 = "$dir/test2";
46+
$link = "$dir/test";
47+
$file1 = "$dir1/index.php";
48+
$file2 = "$dir2/index.php";
49+
$main = "$dir/main.php";
50+
@unlink($main);
51+
@unlink($link);
52+
@unlink($file1);
53+
@unlink($file2);
54+
@rmdir($dir1);
55+
@rmdir($dir2);
56+
?>
57+
--EXPECT--
58+
TEST 1
59+
TEST 1
60+
TEST 2
61+
TEST 2

0 commit comments

Comments
 (0)