From 9e4ba2871bbd80ebeea19cb6d3c271a433fca4ec Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Sat, 19 Nov 2022 14:02:38 +0100 Subject: [PATCH] Do not resolve constants on non-linked class during preloading --- ext/opcache/ZendAccelerator.c | 2 +- ext/opcache/tests/gh9968-1.inc | 3 +++ ext/opcache/tests/gh9968-2.inc | 15 +++++++++++++++ ext/opcache/tests/gh9968.phpt | 27 +++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 ext/opcache/tests/gh9968-1.inc create mode 100644 ext/opcache/tests/gh9968-2.inc create mode 100644 ext/opcache/tests/gh9968.phpt diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index ed38d9a0e588..e5d7f650045c 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -3975,7 +3975,7 @@ static void preload_link(void) if (ce->type == ZEND_INTERNAL_CLASS) { 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 */ CG(in_compilation) = 1; /* prevent autoloading */ if (preload_try_resolve_constants(ce)) { diff --git a/ext/opcache/tests/gh9968-1.inc b/ext/opcache/tests/gh9968-1.inc new file mode 100644 index 000000000000..468178c78483 --- /dev/null +++ b/ext/opcache/tests/gh9968-1.inc @@ -0,0 +1,3 @@ + +--FILE-- + +==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