1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.4' into PHP-8.5

* PHP-8.4:
  Fix preloaded constant erroneously propagated to file-cached script
This commit is contained in:
Ilija Tovilo
2026-02-24 17:30:14 +01:00
5 changed files with 59 additions and 0 deletions

3
NEWS
View File

@@ -2,6 +2,9 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.5.5
- Opcache:
. Fixed bug GH-21052 (Preloaded constant erroneously propagated to file-cached
script). (ilutov)
12 Mar 2026, PHP 8.5.4

View File

@@ -779,6 +779,9 @@ static bool zend_optimizer_ignore_class(zval *ce_zv, zend_string *filename)
zend_class_entry *ce = Z_PTR_P(ce_zv);
if (ce->ce_flags & ZEND_ACC_PRELOADED) {
if (CG(compiler_options) & ZEND_COMPILE_WITH_FILE_CACHE) {
return true;
}
Bucket *ce_bucket = (Bucket*)((uintptr_t)ce_zv - XtOffsetOf(Bucket, val));
size_t offset = ce_bucket - EG(class_table)->arData;
if (offset < EG(persistent_classes_count)) {
@@ -797,6 +800,9 @@ static bool zend_optimizer_ignore_function(zval *fbc_zv, zend_string *filename)
return false;
} else if (fbc->type == ZEND_USER_FUNCTION) {
if (fbc->op_array.fn_flags & ZEND_ACC_PRELOADED) {
if (CG(compiler_options) & ZEND_COMPILE_WITH_FILE_CACHE) {
return true;
}
Bucket *fbc_bucket = (Bucket*)((uintptr_t)fbc_zv - XtOffsetOf(Bucket, val));
size_t offset = fbc_bucket - EG(function_table)->arData;
if (offset < EG(persistent_functions_count)) {

View File

@@ -0,0 +1,32 @@
--TEST--
GH-21052: Preloaded constant erroneously propagated to file-cached script
--CREDITS--
Grummfy
--EXTENSIONS--
opcache
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_cache="{TMP}"
opcache.preload={PWD}/gh21052_a.inc
--SKIPIF--
<?php
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
?>
--FILE--
<?php
require __DIR__ . '/gh21052_b.inc';
?>
--EXPECT--
array(1) {
[0]=>
string(3) "foo"
}
array(1) {
[0]=>
string(3) "foo"
}
array(1) {
[0]=>
string(3) "foo"
}

View File

@@ -0,0 +1,13 @@
<?php
class A {
const C = ['foo'];
public static function test() {
return ['foo'];
}
}
function test() {
return ['foo'];
}

View File

@@ -0,0 +1,5 @@
<?php
var_dump(A::C);
var_dump(A::test());
var_dump(test());