Skip to content

Commit ddfb44f

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2: Fixed bug #77339 (__callStatic may get incorrect arguments)
2 parents 69f54dd + 7e597f4 commit ddfb44f

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 7.3.2
44

5+
- Core:
6+
. Fixed bug #77339 (__callStatic may get incorrect arguments). (Dmitry)
7+
58
- SPL:
69
. Fixed bug #77298 (segfault occurs when add property to unserialized empty
710
ArrayObject). (jhdxr)

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
@@ -4153,6 +4153,14 @@ void zend_compile_static_call(znode *result, zend_ast *ast, uint32_t type) /* {{
41534153
if (ce) {
41544154
zend_string *lcname = Z_STR_P(CT_CONSTANT(opline->op2) + 1);
41554155
fbc = zend_hash_find_ptr(&ce->function_table, lcname);
4156+
if (fbc && !(fbc->common.fn_flags & ZEND_ACC_PUBLIC)) {
4157+
if (ce != CG(active_class_entry)
4158+
&&((fbc->common.fn_flags & ZEND_ACC_PRIVATE)
4159+
|| !zend_check_protected(zend_get_function_root_class(fbc), CG(active_class_entry)))) {
4160+
/* incompatibe function */
4161+
fbc = NULL;
4162+
}
4163+
}
41564164
}
41574165
}
41584166

0 commit comments

Comments
 (0)