com php-src: Fixed bug #78898: NEWS Zend/tests/bug78898.phpt Zend/zend_API.c

From: Date: Wed, 04 Dec 2019 08:40:48 +0000
Subject: com php-src: Fixed bug #78898: NEWS Zend/tests/bug78898.phpt Zend/zend_API.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-109372@lists.php.net to get a copy of this message
Commit: 6540797f1ef5116d9c806baebc43582980db242d Author: Nikita Popov <nikita.ppv@gmail.com> Wed, 4 Dec 2019 09:40:48 +0100 Parents: 9533a815d50df3f916b133ca7d9885c3d0d8ff92 Branches: PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6540797f1ef5116d9c806baebc43582980db242d Log: Fixed bug #78898 Bugs: https://bugs.php.net/78898 Changed paths: M NEWS A Zend/tests/bug78898.phpt M Zend/zend_API.c Diff: diff --git a/NEWS b/NEWS index 1c7775c45f3..82f20812c01 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,8 @@ PHP NEWS (Antony Dovgal, Dmitry) . Fixed bug #78296 (is_file fails to detect file). (cmb) . Fixed bug #78883 (fgets(STDIN) fails on Windows). (cmb) + . Fixed bug #78898 (call_user_func(['parent', ...]) fails while other + succeed). (Nikita) - GD: . Fixed bug #78849 (GD build broken with -D SIGNED_COMPARE_SLOW). (cmb) diff --git a/Zend/tests/bug78898.phpt b/Zend/tests/bug78898.phpt new file mode 100644 index 00000000000..9efd1416e20 --- /dev/null +++ b/Zend/tests/bug78898.phpt @@ -0,0 +1,34 @@ +--TEST-- +Bug #78898: call_user_func(['parent', ...]) fails while other succeed +--FILE-- +<?php + +class A +{ + protected function _x() + { + echo "a"; + } + + public function __call($methodName, array $arguments) + { + throw new Exception("Unknown method."); + } +} + +class B extends A +{ + public function x() + { + parent::_x(); + call_user_func('parent::_x'); + call_user_func(['parent', '_x']); + } +} + +$b = new B; +$b->x(); + +?> +--EXPECT-- +aaa diff --git a/Zend/zend_API.c b/Zend/zend_API.c index e7566194fcf..195dd7d3d7c 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -3117,11 +3117,13 @@ static zend_always_inline int zend_is_callable_check_func(int check_flags, zval ((fcc->object && fcc->calling_scope->__call) || (!fcc->object && fcc->calling_scope->__callstatic)))) { scope = zend_get_executed_scope(); - if (fcc->function_handler->common.scope != scope - || !zend_check_protected(zend_get_function_root_class(fcc->function_handler), scope)) { - retval = 0; - fcc->function_handler = NULL; - goto get_function_via_handler; + if (fcc->function_handler->common.scope != scope) { + if ((fcc->function_handler->common.fn_flags & ZEND_ACC_PRIVATE) + || !zend_check_protected(zend_get_function_root_class(fcc->function_handler), scope)) { + retval = 0; + fcc->function_handler = NULL; + goto get_function_via_handler; + } } } } else {

« previous php.cvs (#109372) next »