mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.5'
* PHP-8.5: Fix preloaded constant erroneously propagated to file-cached script
This commit is contained in:
@@ -779,6 +779,9 @@ static bool zend_optimizer_ignore_class(zval *ce_zv, const zend_string *filename
|
||||
const 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;
|
||||
}
|
||||
const Bucket *ce_bucket = (const 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, const zend_string *file
|
||||
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;
|
||||
}
|
||||
const Bucket *fbc_bucket = (const Bucket*)((uintptr_t)fbc_zv - XtOffsetOf(Bucket, val));
|
||||
size_t offset = fbc_bucket - EG(function_table)->arData;
|
||||
if (offset < EG(persistent_functions_count)) {
|
||||
|
||||
32
ext/opcache/tests/gh21052.phpt
Normal file
32
ext/opcache/tests/gh21052.phpt
Normal 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"
|
||||
}
|
||||
13
ext/opcache/tests/gh21052_a.inc
Normal file
13
ext/opcache/tests/gh21052_a.inc
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
class A {
|
||||
const C = ['foo'];
|
||||
|
||||
public static function test() {
|
||||
return ['foo'];
|
||||
}
|
||||
}
|
||||
|
||||
function test() {
|
||||
return ['foo'];
|
||||
}
|
||||
5
ext/opcache/tests/gh21052_b.inc
Normal file
5
ext/opcache/tests/gh21052_b.inc
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
var_dump(A::C);
|
||||
var_dump(A::test());
|
||||
var_dump(test());
|
||||
Reference in New Issue
Block a user