diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 9398b58ac6b..1850bb3f197 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -1157,8 +1157,9 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr zend_persistent_script *existing_persistent_script = (zend_persistent_script *)bucket->data; if (!existing_persistent_script->corrupted) { - if (!ZCG(accel_directives).validate_timestamps || - (new_persistent_script->timestamp == existing_persistent_script->timestamp)) { + if (!ZCG(accel_directives).revalidate_path && + (!ZCG(accel_directives).validate_timestamps || + (new_persistent_script->timestamp == existing_persistent_script->timestamp))) { zend_accel_add_key(key, key_length, bucket TSRMLS_CC); } zend_shared_alloc_unlock(TSRMLS_C); @@ -1199,7 +1200,7 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr /* store script structure in the hash table */ bucket = zend_accel_hash_update(&ZCSG(hash), new_persistent_script->full_path, new_persistent_script->full_path_len + 1, 0, new_persistent_script); - if (bucket && + if (bucket && !ZCG(accel_directives).revalidate_path && /* key may contain non-persistent PHAR aliases (see issues #115 and #149) */ memcmp(key, "phar://", sizeof("phar://") - 1) != 0 && (new_persistent_script->full_path_len != key_length || diff --git a/ext/opcache/tests/revalidate_path_01.phpt b/ext/opcache/tests/revalidate_path_01.phpt new file mode 100644 index 00000000000..cf2ac0d8296 --- /dev/null +++ b/ext/opcache/tests/revalidate_path_01.phpt @@ -0,0 +1,61 @@ +--TEST-- +revalidate_path 01: OPCache must cache only resolved real paths when revalidate_path is set +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.revalidate_path=1 +--SKIPIF-- + + +--FILE-- + +--CLEAN-- + +--EXPECT-- +TEST 1 +TEST 1 +TEST 2 +TEST 2