From 3f29ce5067647f5eb9158cdb2aa24392e258700f Mon Sep 17 00:00:00 2001 From: Aleksey Parshukov Date: Wed, 3 Jul 2013 12:07:46 +0400 Subject: [PATCH 1/4] remove XFAIL for bug #48770 --- Zend/tests/bug48770.phpt | 2 -- Zend/tests/bug48770_2.phpt | 2 -- Zend/tests/bug48770_3.phpt | 2 -- 3 files changed, 6 deletions(-) diff --git a/Zend/tests/bug48770.phpt b/Zend/tests/bug48770.phpt index 40fa84157b716..4e2794a4ad0f2 100644 --- a/Zend/tests/bug48770.phpt +++ b/Zend/tests/bug48770.phpt @@ -1,7 +1,5 @@ --TEST-- Bug #48770 (call_user_func_array() fails to call parent from inheriting class) ---XFAIL-- -See Bug #48770 --FILE-- Date: Tue, 2 Jul 2013 19:37:24 +0400 Subject: [PATCH 2/4] test call_user_func(), when fails to call self from inheriting class --- Zend/tests/call_user_func_006.phpt | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Zend/tests/call_user_func_006.phpt diff --git a/Zend/tests/call_user_func_006.phpt b/Zend/tests/call_user_func_006.phpt new file mode 100644 index 0000000000000..583053c35714c --- /dev/null +++ b/Zend/tests/call_user_func_006.phpt @@ -0,0 +1,29 @@ +--TEST-- +Testing call_user_func with self call in same class (not parent) +--FILE-- +run('This should work!'); + +?> +--EXPECTF-- +%unicode|string%(26) "A::func: This should work!" +%unicode|string%(26) "A::func: This should work!" + From 8a0b16940b1389bf0bec7320af84aac24a83c77a Mon Sep 17 00:00:00 2001 From: Aleksey Parshukov Date: Wed, 3 Jul 2013 11:46:07 +0400 Subject: [PATCH 3/4] test call_user_func() without class scope --- .../general_functions/callbacks_001.phpt | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/ext/standard/tests/general_functions/callbacks_001.phpt b/ext/standard/tests/general_functions/callbacks_001.phpt index a58f19d932b8e..8c3a2209bfbb6 100644 --- a/ext/standard/tests/general_functions/callbacks_001.phpt +++ b/ext/standard/tests/general_functions/callbacks_001.phpt @@ -78,6 +78,21 @@ echo "===FOREIGN===\n"; $o = new P; $o->test(); +echo "===WITHOUT SCOPE===\n"; +function call($cb) { + echo join('|', $cb) . "\n"; + call_user_func($cb); +} +call(array($o, 'who')); +call(array($o, 'O::who')); +call(array($o, 'P::who')); +call(array($o, 'B::who')); +call(array($o, 'parent::who')); + +call(array('parent', 'who')); +call(array('C', 'parent::who')); +call(array('C', 'who')); + ?> ===DONE=== --EXPECTF-- @@ -105,4 +120,23 @@ O $this|B::who Warning: call_user_func() expects parameter 1 to be a valid callback, class 'P' is not a subclass of 'B' in %s on line %d -===DONE=== +===WITHOUT SCOPE=== +$this|who +P +$this|O::who +O +$this|P::who +P +$this|B::who + +Warning: call_user_func() expects parameter 1 to be a valid callback, class 'P' is not a subclass of 'B' in %s on line %d +$this|parent::who +O +parent|who + +Warning: call_user_func() expects parameter 1 to be a valid callback, cannot access parent:: when no class scope is active in %s on line %d +C|parent::who +B +C|who +B +===DONE=== \ No newline at end of file From 2aaf0d13201bf66b64882a7a36c5cfba3b025f72 Mon Sep 17 00:00:00 2001 From: Aleksey Parshukov Date: Wed, 3 Jul 2013 11:22:12 +0400 Subject: [PATCH 4/4] Fixed bug #48770: when call_user_func() fails to call parent from inheriting class --- Zend/zend_API.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 90d27b79878b7..32e4e5686f24a 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -3049,9 +3049,10 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval *object_ptr, uint ch return 0; } - fcc->calling_scope = Z_OBJCE_PP(obj); /* TBFixed: what if it's overloaded? */ - fcc->object_ptr = *obj; + fcc->calling_scope = instanceof_function(Z_OBJCE_PP(obj), EG(scope) TSRMLS_CC) + ? EG(scope) + : Z_OBJCE_PP(obj); if (callable_name) { char *ptr; @@ -3107,7 +3108,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval *object_ptr, uint ch if (Z_OBJ_HANDLER_P(callable, get_closure) && Z_OBJ_HANDLER_P(callable, get_closure)(callable, &fcc->calling_scope, &fcc->function_handler, &fcc->object_ptr TSRMLS_CC) == SUCCESS) { fcc->called_scope = fcc->calling_scope; if (callable_name) { - zend_class_entry *ce = Z_OBJCE_P(callable); /* TBFixed: what if it's overloaded? */ + zend_class_entry *ce = Z_OBJCE_P(callable); *callable_name_len = ce->name_length + sizeof("::__invoke") - 1; *callable_name = emalloc(*callable_name_len + 1);