mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
Fix Closure::call() on internal method closure
In this case we should use the original internal handler. Otherwise the trampoline will attempt to free the closure, but the function being used is not actually part of a closure anymore.
This commit is contained in:
parent
526407ca35
commit
eda9f5f740
10
Zend/tests/closure_call_internal.phpt
Normal file
10
Zend/tests/closure_call_internal.phpt
Normal file
@ -0,0 +1,10 @@
|
||||
--TEST--
|
||||
Closure::call() on internal method
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
var_dump(Closure::fromCallable([new DateTime(), 'getTimestamp'])->call(new DateTime('@123')));
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
int(123)
|
@ -152,6 +152,9 @@ ZEND_METHOD(Closure, call)
|
||||
my_function.common.fn_flags &= ~ZEND_ACC_CLOSURE;
|
||||
/* use scope of passed object */
|
||||
my_function.common.scope = Z_OBJCE_P(newthis);
|
||||
if (closure->func.type == ZEND_INTERNAL_FUNCTION) {
|
||||
my_function.internal_function.handler = closure->orig_internal_handler;
|
||||
}
|
||||
fci_cache.function_handler = &my_function;
|
||||
|
||||
/* Runtime cache relies on bound scope to be immutable, hence we need a separate rt cache in case scope changed */
|
||||
|
Loading…
Reference in New Issue
Block a user