From e0d6c3f7bae2644802f13bd1ae1f49c3d08a8e07 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 4 Nov 2020 10:54:08 +0100 Subject: [PATCH] Fix dynamic function definition in preload script We should use normal function renaming if the function is declared during preloading itself, rather than afterwards. This fixes a regression introduced by 68f80be9d1380de731930187250a7ed6b55ae196. --- Zend/zend_compile.c | 3 ++- ext/opcache/tests/preload_dynamic_function.inc | 4 ++++ .../tests/preload_dynamic_function.phpt | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 ext/opcache/tests/preload_dynamic_function.inc create mode 100644 ext/opcache/tests/preload_dynamic_function.phpt diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 810e384177..df4cd4b2f3 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1050,7 +1050,8 @@ ZEND_API int do_bind_function(zval *lcname) /* {{{ */ return FAILURE; } function = (zend_function*)Z_PTR_P(zv); - if (UNEXPECTED(function->common.fn_flags & ZEND_ACC_PRELOADED)) { + if (UNEXPECTED(function->common.fn_flags & ZEND_ACC_PRELOADED) + && !(CG(compiler_options) & ZEND_COMPILE_PRELOAD)) { zv = zend_hash_add(EG(function_table), Z_STR_P(lcname), zv); } else { zv = zend_hash_set_bucket_key(EG(function_table), (Bucket*)zv, Z_STR_P(lcname)); diff --git a/ext/opcache/tests/preload_dynamic_function.inc b/ext/opcache/tests/preload_dynamic_function.inc new file mode 100644 index 0000000000..3caa9592b8 --- /dev/null +++ b/ext/opcache/tests/preload_dynamic_function.inc @@ -0,0 +1,4 @@ + +--FILE-- + +--EXPECT-- +bool(true) -- 2.50.1