Skip to content

Commit 99ddc80

Browse files
committed
Discard constants before preload_load()
We don't preload constants, so we should also not cache constant evaluations based on them, as a different value may be defined at runtime.
1 parent af50e68 commit 99ddc80

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4528,17 +4528,6 @@ static int accel_preload(const char *config, bool in_child)
45284528
goto finish;
45294529
}
45304530

4531-
/* Inheritance errors may be thrown during linking */
4532-
zend_try {
4533-
preload_link();
4534-
} zend_catch {
4535-
CG(map_ptr_last) = orig_map_ptr_last;
4536-
ret = FAILURE;
4537-
goto finish;
4538-
} zend_end_try();
4539-
4540-
preload_remove_empty_includes();
4541-
45424531
/* Don't preload constants */
45434532
if (EG(zend_constants)) {
45444533
zend_string *key;
@@ -4569,6 +4558,17 @@ static int accel_preload(const char *config, bool in_child)
45694558
} ZEND_HASH_FOREACH_END_DEL();
45704559
}
45714560

4561+
/* Inheritance errors may be thrown during linking */
4562+
zend_try {
4563+
preload_link();
4564+
} zend_catch {
4565+
CG(map_ptr_last) = orig_map_ptr_last;
4566+
ret = FAILURE;
4567+
goto finish;
4568+
} zend_end_try();
4569+
4570+
preload_remove_empty_includes();
4571+
45724572
script = create_persistent_script();
45734573
script->ping_auto_globals_mask = ping_auto_globals_mask;
45744574

ext/opcache/tests/bug78376.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows
1313
?>
1414
--FILE--
1515
<?php
16+
const CNST = 'bbbb';
1617
var_dump(\A::$a);
1718
?>
1819
--EXPECT--
19-
string(4) "aaaa"
20+
string(4) "bbbb"

0 commit comments

Comments
 (0)