Last active
October 28, 2019 13:52
-
-
Save dstogov/6f7fc7ed5c335e309675653bc6cebffa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c | |
index 23ea9bc2e2..aa80d0a8c5 100644 | |
--- a/Zend/zend_closures.c | |
+++ b/Zend/zend_closures.c | |
@@ -226,6 +226,21 @@ ZEND_METHOD(Closure, bind) | |
} | |
/* }}} */ | |
+static ZEND_NAMED_FUNCTION(zend_closure_call_invoke) /* {{{ */ | |
+{ | |
+ zend_function *func = EX(func); | |
+ zval *arguments = ZEND_CALL_ARG(execute_data, 1); | |
+ | |
+ if (call_user_function_ex(CG(function_table), NULL, getThis(), return_value, ZEND_NUM_ARGS(), arguments, 1, NULL) == FAILURE) { | |
+ RETVAL_FALSE; | |
+ } | |
+ | |
+#if ZEND_DEBUG | |
+ execute_data->func = NULL; | |
+#endif | |
+} | |
+/* }}} */ | |
+ | |
static ZEND_NAMED_FUNCTION(zend_closure_call_magic) /* {{{ */ { | |
zend_fcall_info fci; | |
zend_fcall_info_cache fcc; | |
@@ -271,9 +286,13 @@ static int zend_create_closure_from_callable(zval *return_value, zval *callable, | |
memset(&call, 0, sizeof(zend_internal_function)); | |
call.type = ZEND_INTERNAL_FUNCTION; | |
- call.handler = zend_closure_call_magic; | |
- call.function_name = mptr->common.function_name; | |
- call.arg_info = (zend_internal_arg_info *) mptr->common.prototype; | |
+ if (mptr->type == ZEND_USER_FUNCTION) { | |
+ call.handler = zend_closure_call_magic; | |
+ call.function_name = mptr->common.function_name; | |
+ call.arg_info = (zend_internal_arg_info *) mptr->common.prototype; | |
+ } else { | |
+ call.handler = zend_closure_call_invoke; | |
+ } | |
call.scope = mptr->common.scope; | |
zend_free_trampoline(mptr); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment