Skip to content

Commit a298bde

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fixed bug #78898
2 parents 7b7115c + 6540797 commit a298bde

File tree

2 files changed

+41
-5
lines changed

2 files changed

+41
-5
lines changed

Zend/tests/bug78898.phpt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
Bug #78898: call_user_func(['parent', ...]) fails while other succeed
3+
--FILE--
4+
<?php
5+
6+
class A
7+
{
8+
protected function _x()
9+
{
10+
echo "a";
11+
}
12+
13+
public function __call($methodName, array $arguments)
14+
{
15+
throw new Exception("Unknown method.");
16+
}
17+
}
18+
19+
class B extends A
20+
{
21+
public function x()
22+
{
23+
parent::_x();
24+
call_user_func('parent::_x');
25+
call_user_func(['parent', '_x']);
26+
}
27+
}
28+
29+
$b = new B;
30+
$b->x();
31+
32+
?>
33+
--EXPECT--
34+
aaa

Zend/zend_API.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2933,11 +2933,13 @@ static zend_always_inline int zend_is_callable_check_func(int check_flags, zval
29332933
((fcc->object && fcc->calling_scope->__call) ||
29342934
(!fcc->object && fcc->calling_scope->__callstatic)))) {
29352935
scope = zend_get_executed_scope();
2936-
if (fcc->function_handler->common.scope != scope
2937-
|| !zend_check_protected(zend_get_function_root_class(fcc->function_handler), scope)) {
2938-
retval = 0;
2939-
fcc->function_handler = NULL;
2940-
goto get_function_via_handler;
2936+
if (fcc->function_handler->common.scope != scope) {
2937+
if ((fcc->function_handler->common.fn_flags & ZEND_ACC_PRIVATE)
2938+
|| !zend_check_protected(zend_get_function_root_class(fcc->function_handler), scope)) {
2939+
retval = 0;
2940+
fcc->function_handler = NULL;
2941+
goto get_function_via_handler;
2942+
}
29412943
}
29422944
}
29432945
} else {

0 commit comments

Comments
 (0)