Skip to content

Commit 773ed62

Browse files
committed
Merge branch 'PHP-7.3'
* PHP-7.3: Fixed bug #77339 (__callStatic may get incorrect arguments)
2 parents b95cd92 + ddfb44f commit 773ed62

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

Zend/tests/bug77339.phpt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Bug #77339 (__callStatic may get incorrect arguments)
3+
--FILE--
4+
<?php
5+
class Foo
6+
{
7+
static function __callStatic($name, $arguments) {
8+
if ($name === 'get') {
9+
if (!isset($arguments[0])) {
10+
var_dump(['getSomeWhat']);
11+
var_dump($arguments);
12+
exit;
13+
}
14+
}
15+
echo "OK\n";
16+
}
17+
18+
protected function get ($key) {
19+
echo "BUG!!!\n";
20+
}
21+
}
22+
23+
class Bar
24+
{
25+
static function __callStatic($name, $arguments) {
26+
echo Foo::get('getSomeWhat');
27+
}
28+
}
29+
30+
Bar::someUndefinedStaticFunction();
31+
?>
32+
--EXPECT--
33+
OK

Zend/zend_compile.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4055,6 +4055,14 @@ void zend_compile_static_call(znode *result, zend_ast *ast, uint32_t type) /* {{
40554055
if (ce) {
40564056
zend_string *lcname = Z_STR_P(CT_CONSTANT(opline->op2) + 1);
40574057
fbc = zend_hash_find_ptr(&ce->function_table, lcname);
4058+
if (fbc && !(fbc->common.fn_flags & ZEND_ACC_PUBLIC)) {
4059+
if (ce != CG(active_class_entry)
4060+
&&((fbc->common.fn_flags & ZEND_ACC_PRIVATE)
4061+
|| !zend_check_protected(zend_get_function_root_class(fbc), CG(active_class_entry)))) {
4062+
/* incompatibe function */
4063+
fbc = NULL;
4064+
}
4065+
}
40584066
}
40594067
}
40604068

0 commit comments

Comments
 (0)