diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index b1c86e79c24..f71468549e6 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -3983,7 +3983,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) = true; /* 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 00000000000..468178c7848 --- /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