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