mirror of
https://github.com/php/php-src.git
synced 2025-08-20 17:34:35 +02:00
Merge branch 'PHP-8.2'
* PHP-8.2: [ci skip] NEWS [ci skip] NEWS Do not resolve constants on non-linked class during preloading (#9975)
This commit is contained in:
commit
1cba98ebe9
4 changed files with 46 additions and 1 deletions
|
@ -3983,7 +3983,7 @@ static void preload_link(void)
|
||||||
if (ce->type == ZEND_INTERNAL_CLASS) {
|
if (ce->type == ZEND_INTERNAL_CLASS) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
|
if ((ce->ce_flags & ZEND_ACC_LINKED) && !(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
|
||||||
if (!(ce->ce_flags & ZEND_ACC_TRAIT)) { /* don't update traits */
|
if (!(ce->ce_flags & ZEND_ACC_TRAIT)) { /* don't update traits */
|
||||||
CG(in_compilation) = true; /* prevent autoloading */
|
CG(in_compilation) = true; /* prevent autoloading */
|
||||||
if (preload_try_resolve_constants(ce)) {
|
if (preload_try_resolve_constants(ce)) {
|
||||||
|
|
3
ext/opcache/tests/gh9968-1.inc
Normal file
3
ext/opcache/tests/gh9968-1.inc
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
opcache_compile_file('ext/opcache/tests/gh9968-2.inc');
|
15
ext/opcache/tests/gh9968-2.inc
Normal file
15
ext/opcache/tests/gh9968-2.inc
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class Root1_Constant_Definer
|
||||||
|
{
|
||||||
|
const CONSTANT = 'value';
|
||||||
|
}
|
||||||
|
|
||||||
|
class Root1_Constant_Empty
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
class Root1_Constant_Referencer extends Root2_Empty_Empty
|
||||||
|
{
|
||||||
|
protected $propertyReferencingAnExternalConstant = Root1_Constant_Definer::CONSTANT;
|
||||||
|
}
|
27
ext/opcache/tests/gh9968.phpt
Normal file
27
ext/opcache/tests/gh9968.phpt
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
--TEST--
|
||||||
|
GH-9968: Preload crash on non-linked class
|
||||||
|
--INI--
|
||||||
|
opcache.enable=1
|
||||||
|
opcache.enable_cli=1
|
||||||
|
opcache.optimization_level=-1
|
||||||
|
opcache.preload={PWD}/gh9968-1.inc
|
||||||
|
--EXTENSIONS--
|
||||||
|
opcache
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
new Root1_Constant_Referencer();
|
||||||
|
|
||||||
|
?>
|
||||||
|
==DONE==
|
||||||
|
--EXPECTF--
|
||||||
|
Warning: Can't preload unlinked class Root1_Constant_Referencer: Unknown parent Root2_Empty_Empty in %s on line %d
|
||||||
|
|
||||||
|
Fatal error: Uncaught Error: Class "Root1_Constant_Referencer" not found in %s:%d
|
||||||
|
Stack trace:
|
||||||
|
#0 {main}
|
||||||
|
thrown in %s on line %d
|
Loading…
Add table
Add a link
Reference in a new issue