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));
--- /dev/null
+<?php
+if (1) {
+ function f() {}
+}
--- /dev/null
+--TEST--
+Defining a dynamic function inside the preload script
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+opcache.preload={PWD}/preload_dynamic_function.inc
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
+?>
+--FILE--
+<?php
+var_dump(function_exists("f"));
+?>
+--EXPECT--
+bool(true)