From: Nikita Popov Date: Wed, 4 Nov 2020 09:54:08 +0000 (+0100) Subject: Fix dynamic function definition in preload script X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e0d6c3f7bae2644802f13bd1ae1f49c3d08a8e07;p=php 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. --- 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)