summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-12-04 09:40:48 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-12-04 09:40:48 +0100
commit6540797f1ef5116d9c806baebc43582980db242d (patch)
tree7d67c070e1870c6ba75033d1cc3bd8ff330c7a5b
parent9533a815d50df3f916b133ca7d9885c3d0d8ff92 (diff)
downloadphp-git-6540797f1ef5116d9c806baebc43582980db242d.tar.gz
Fixed bug #78898
-rw-r--r--NEWS2
-rw-r--r--Zend/tests/bug78898.phpt34
-rw-r--r--Zend/zend_API.c12
3 files changed, 43 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index 1c7775c45f..82f20812c0 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 0000000000..9efd1416e2
--- /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 e7566194fc..195dd7d3d7 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 {