diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2019-09-23 23:48:36 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2019-09-24 16:08:42 +0200 |
commit | 0c7124e6beff0a7b0540691db370148be06d242a (patch) | |
tree | b37b67cf5a92c16680c837390a20c9ff52731e5e /Zend/zend_API.c | |
parent | 1fe47ad233b45f3313e8942c3190fd5ca03952f0 (diff) | |
download | php-git-0c7124e6beff0a7b0540691db370148be06d242a.tar.gz |
Add check_only parameter to get_closure handler
`get_closure` handlers are called to check whether an object is
callable, and to actually get the closure, respectively. The behavior
of the handler might differ for these two cases, particularly the
handler may throw in the latter case, but should not in the former.
Therefore we add a `check_only` parameter, to be able to distinguish
the desired purpose.
Diffstat (limited to 'Zend/zend_API.c')
-rw-r--r-- | Zend/zend_API.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 472d886467..34fcf1506a 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -3105,7 +3105,7 @@ try_again: zend_object *zobj = Z_OBJ_P(callable); if (zobj->handlers->get_closure - && zobj->handlers->get_closure(zobj, &calling_scope, &fptr, &object) == SUCCESS) { + && zobj->handlers->get_closure(zobj, &calling_scope, &fptr, &object, 1) == SUCCESS) { zend_class_entry *ce = zobj->ce; zend_string *callable_name = zend_string_alloc( ZSTR_LEN(ce->name) + sizeof("::__invoke") - 1, 0); @@ -3230,18 +3230,12 @@ check_func: } return 0; case IS_OBJECT: - if (Z_OBJ_HANDLER_P(callable, get_closure)) { - if (Z_OBJ_HANDLER_P(callable, get_closure)(Z_OBJ_P(callable), &fcc->calling_scope, &fcc->function_handler, &fcc->object) == SUCCESS) { + if (Z_OBJ_HANDLER_P(callable, get_closure) && Z_OBJ_HANDLER_P(callable, get_closure)(Z_OBJ_P(callable), &fcc->calling_scope, &fcc->function_handler, &fcc->object, 1) == SUCCESS) { fcc->called_scope = fcc->calling_scope; if (fcc == &fcc_local) { zend_release_fcall_info_cache(fcc); } return 1; - } else { - /* Discard exceptions thrown from Z_OBJ_HANDLER_P(callable, get_closure) - TODO: extend get_closure() with additional argument and prevent exception throwing in the first place */ - zend_clear_exception(); - } } if (error) *error = estrdup("no array or string given"); return 0; |