File tree 4 files changed +46
-1
lines changed
4 files changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -3983,7 +3983,7 @@ static void preload_link(void)
3983
3983
if (ce -> type == ZEND_INTERNAL_CLASS ) {
3984
3984
break ;
3985
3985
}
3986
- if (!(ce -> ce_flags & ZEND_ACC_CONSTANTS_UPDATED )) {
3986
+ if (( ce -> ce_flags & ZEND_ACC_LINKED ) && !(ce -> ce_flags & ZEND_ACC_CONSTANTS_UPDATED )) {
3987
3987
if (!(ce -> ce_flags & ZEND_ACC_TRAIT )) { /* don't update traits */
3988
3988
CG (in_compilation ) = true; /* prevent autoloading */
3989
3989
if (preload_try_resolve_constants (ce )) {
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ opcache_compile_file ('ext/opcache/tests/gh9968-2.inc ' );
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ class Root1_Constant_Definer
4
+ {
5
+ const CONSTANT = 'value ' ;
6
+ }
7
+
8
+ class Root1_Constant_Empty
9
+ {
10
+ }
11
+
12
+ class Root1_Constant_Referencer extends Root2_Empty_Empty
13
+ {
14
+ protected $ propertyReferencingAnExternalConstant = Root1_Constant_Definer::CONSTANT ;
15
+ }
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-9968: Preload crash on non-linked class
3
+ --INI--
4
+ opcache.enable=1
5
+ opcache.enable_cli=1
6
+ opcache.optimization_level=-1
7
+ opcache.preload={PWD}/gh9968-1.inc
8
+ --EXTENSIONS--
9
+ opcache
10
+ --SKIPIF--
11
+ <?php
12
+ if (PHP_OS_FAMILY == 'Windows ' ) die ('skip Preloading is not supported on Windows ' );
13
+ ?>
14
+ --FILE--
15
+ <?php
16
+
17
+ new Root1_Constant_Referencer ();
18
+
19
+ ?>
20
+ ==DONE==
21
+ --EXPECTF--
22
+ Warning: Can't preload unlinked class Root1_Constant_Referencer: Unknown parent Root2_Empty_Empty in %s on line %d
23
+
24
+ Fatal error: Uncaught Error: Class "Root1_Constant_Referencer" not found in %s:%d
25
+ Stack trace:
26
+ #0 {main}
27
+ thrown in %s on line %d
You can’t perform that action at this time.
0 commit comments