Skip to content

Commit b354184

Browse files
committed
Allocate map_ptr for mutable_data during preloading
We need to discard objects in the class constants if they happened to be evaluated during preloading. To allow doing so, we need to use mutable_data, which will place the evaluated constants into a separate table.
1 parent aef3bb7 commit b354184

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

Zend/zend_compile.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7687,6 +7687,7 @@ void zend_compile_class_decl(znode *result, zend_ast *ast, bool toplevel) /* {{{
76877687
if (CG(compiler_options) & ZEND_COMPILE_PRELOAD) {
76887688
ce->ce_flags |= ZEND_ACC_PRELOADED;
76897689
ZEND_MAP_PTR_NEW(ce->static_members_table);
7690+
ZEND_MAP_PTR_NEW(ce->mutable_data);
76907691
}
76917692

76927693
ce->ce_flags |= decl->flags;

ext/opcache/tests/preload_enum.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ enum MyEnum {
44
case Foo;
55
case Bar;
66
}
7+
var_dump(MyEnum::Bar);

ext/opcache/tests/preload_enum.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows
1414
<?php
1515

1616
var_dump(MyEnum::Foo);
17+
var_dump(MyEnum::Bar);
1718

1819
?>
1920
--EXPECT--
21+
enum(MyEnum::Bar)
2022
enum(MyEnum::Foo)
23+
enum(MyEnum::Bar)

0 commit comments

Comments
 (0)