diff --git a/NEWS b/NEWS index 474db936ef15..62353d3107b2 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,8 @@ PHP NEWS - Opcache: . Fixed bug GH-22857 (Function JIT emits wrong code for FETCH_OBJ_FUNC_ARG on a property hook getter, losing register-held variables). (Zhao Hao) + . Fixed crash in observer API calling cases() on an enum preloaded with + opcache_compile_file(). (Thomas Atkinson) - OpenSSL: . Fix missing error check on invalid alpn protocols. (ndossche) diff --git a/Zend/zend_enum.c b/Zend/zend_enum.c index 464e7d801a89..e1190d4e3289 100644 --- a/Zend/zend_enum.c +++ b/Zend/zend_enum.c @@ -418,10 +418,10 @@ static void zend_enum_register_func(zend_class_entry *ce, zend_known_string_id n zif->module = EG(current_module); zif->scope = ce; zif->T = ZEND_OBSERVER_ENABLED; + if (CG(compiler_options) & ZEND_COMPILE_PRELOAD) { + zif->fn_flags |= ZEND_ACC_PRELOADED; + } if (EG(active)) { // at run-time - if (CG(compiler_options) & ZEND_COMPILE_PRELOAD) { - zif->fn_flags |= ZEND_ACC_PRELOADED; - } ZEND_MAP_PTR_INIT(zif->run_time_cache, zend_arena_calloc(&CG(arena), 1, zend_internal_run_time_cache_reserved_size())); } else { #ifdef ZTS diff --git a/ext/opcache/tests/preload_enum_compile_only.inc b/ext/opcache/tests/preload_enum_compile_only.inc new file mode 100644 index 000000000000..fd7eeddd932e --- /dev/null +++ b/ext/opcache/tests/preload_enum_compile_only.inc @@ -0,0 +1,3 @@ + +--FILE-- + +--EXPECT-- +array(2) { + [0]=> + enum(MyEnum::Foo) + [1]=> + enum(MyEnum::Bar) +}