Skip to content

Commit 6540797

Browse files
committed
Fixed bug #78898
1 parent 9533a81 commit 6540797

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ PHP NEWS
1010
(Antony Dovgal, Dmitry)
1111
. Fixed bug #78296 (is_file fails to detect file). (cmb)
1212
. Fixed bug #78883 (fgets(STDIN) fails on Windows). (cmb)
13+
. Fixed bug #78898 (call_user_func(['parent', ...]) fails while other
14+
succeed). (Nikita)
1315

1416
- GD:
1517
. Fixed bug #78849 (GD build broken with -D SIGNED_COMPARE_SLOW). (cmb)

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
@@ -3117,11 +3117,13 @@ static zend_always_inline int zend_is_callable_check_func(int check_flags, zval
31173117
((fcc->object && fcc->calling_scope->__call) ||
31183118
(!fcc->object && fcc->calling_scope->__callstatic)))) {
31193119
scope = zend_get_executed_scope();
3120-
if (fcc->function_handler->common.scope != scope
3121-
|| !zend_check_protected(zend_get_function_root_class(fcc->function_handler), scope)) {
3122-
retval = 0;
3123-
fcc->function_handler = NULL;
3124-
goto get_function_via_handler;
3120+
if (fcc->function_handler->common.scope != scope) {
3121+
if ((fcc->function_handler->common.fn_flags & ZEND_ACC_PRIVATE)
3122+
|| !zend_check_protected(zend_get_function_root_class(fcc->function_handler), scope)) {
3123+
retval = 0;
3124+
fcc->function_handler = NULL;
3125+
goto get_function_via_handler;
3126+
}
31253127
}
31263128
}
31273129
} else {

0 commit comments

Comments
 (0)