Skip to content

Commit 29c9cc9

Browse files
committed
Do not run autoloader when resolving unqualified call
1 parent 5a4623d commit 29c9cc9

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Fallback to global function should not trigger autoloading.
3+
--FILE--
4+
<?php
5+
namespace {
6+
function loader($name) {
7+
echo $name, \PHP_EOL;
8+
}
9+
10+
autoload_register_function('loader');
11+
}
12+
13+
namespace bar {
14+
var_dump('Hello');
15+
}
16+
?>
17+
--EXPECT--
18+
string(5) "Hello"

Zend/zend_vm_def.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -3859,13 +3859,13 @@ ZEND_VM_HOT_HANDLER(69, ZEND_INIT_NS_FCALL_BY_NAME, ANY, CONST, NUM|CACHE_SLOT)
38593859
if (UNEXPECTED(fbc == NULL)) {
38603860
zval *function_name = (zval *)RT_CONSTANT(opline, opline->op2);
38613861
/* Fetch lowercase name stored in the next literal slot */
3862-
fbc = zend_lookup_function_ex(Z_STR_P(function_name), Z_STR_P(function_name+1), /* use_autoload */ true);
3862+
fbc = zend_lookup_function_ex(Z_STR_P(function_name), Z_STR_P(function_name+1), /* use_autoload */ false);
38633863
if (UNEXPECTED(fbc == NULL)) {
38643864
if (UNEXPECTED(EG(exception))) {
38653865
HANDLE_EXCEPTION();
38663866
}
38673867
/* Fallback onto global namespace, by fetching the unqualified lowercase name stored in the second literal slot */
3868-
fbc = zend_lookup_function_ex(Z_STR_P(function_name+2), Z_STR_P(function_name+2), /* use_autoload */ true);
3868+
fbc = zend_lookup_function_ex(Z_STR_P(function_name+2), Z_STR_P(function_name+2), /* use_autoload */ false);
38693869
if (fbc == NULL) {
38703870
if (UNEXPECTED(EG(exception))) {
38713871
HANDLE_EXCEPTION();

Zend/zend_vm_execute.h

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)