mirror of
https://github.com/php/php-src.git
synced 2024-11-27 11:53:33 +08:00
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Invalidate path even if the file was deleted
This commit is contained in:
commit
520fc70245
3
NEWS
3
NEWS
@ -26,6 +26,9 @@ PHP NEWS
|
||||
. Fixed bug GH-12297 (PHP Startup: Invalid library (maybe not a PHP library)
|
||||
'mysqlnd.so' in Unknown on line). (nielsdos)
|
||||
|
||||
- Opcache:
|
||||
. Fixed opcache_invalidate() on deleted file. (mikhainin)
|
||||
|
||||
- SimpleXML:
|
||||
. Apply iterator fixes only on master. (nielsdos)
|
||||
|
||||
|
@ -1391,6 +1391,7 @@ zend_result zend_accel_invalidate(zend_string *filename, bool force)
|
||||
{
|
||||
zend_string *realpath;
|
||||
zend_persistent_script *persistent_script;
|
||||
zend_bool file_found = true;
|
||||
|
||||
if (!ZCG(accelerator_enabled) || accelerator_shm_read_lock() != SUCCESS) {
|
||||
return FAILURE;
|
||||
@ -1399,7 +1400,10 @@ zend_result zend_accel_invalidate(zend_string *filename, bool force)
|
||||
realpath = accelerator_orig_zend_resolve_path(filename);
|
||||
|
||||
if (!realpath) {
|
||||
return FAILURE;
|
||||
//file could have been deleted, but we still need to invalidate it.
|
||||
//so instead of failing, just use the provided filename for the lookup
|
||||
realpath = zend_string_copy(filename);
|
||||
file_found = false;
|
||||
}
|
||||
|
||||
if (ZCG(accel_directives).file_cache) {
|
||||
@ -1424,12 +1428,13 @@ zend_result zend_accel_invalidate(zend_string *filename, bool force)
|
||||
|
||||
file_handle.opened_path = NULL;
|
||||
zend_destroy_file_handle(&file_handle);
|
||||
file_found = true;
|
||||
}
|
||||
|
||||
accelerator_shm_read_unlock();
|
||||
zend_string_release_ex(realpath, 0);
|
||||
|
||||
return SUCCESS;
|
||||
return file_found ? SUCCESS : FAILURE;
|
||||
}
|
||||
|
||||
static zend_string* accel_new_interned_key(zend_string *key)
|
||||
|
26
ext/opcache/tests/opcache_invalidate_deleted_file.phpt
Normal file
26
ext/opcache/tests/opcache_invalidate_deleted_file.phpt
Normal file
@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
opcache_invalidate() should invalidate deleted file
|
||||
--EXTENSIONS--
|
||||
opcache
|
||||
--INI--
|
||||
opcache.enable_cli=1
|
||||
opcache.validate_timestamps=0
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$file = __DIR__ . DIRECTORY_SEPARATOR . pathinfo(__FILE__, PATHINFO_FILENAME) . '.inc';
|
||||
file_put_contents($file, <<<PHP
|
||||
<?php
|
||||
return 42;
|
||||
PHP);
|
||||
var_dump(include $file);
|
||||
unlink($file);
|
||||
var_dump(include $file);
|
||||
opcache_invalidate($file);
|
||||
var_dump(@(include $file));
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
int(42)
|
||||
int(42)
|
||||
bool(false)
|
Loading…
Reference in New Issue
Block a user