Merge branch 'PHP-7.3'

* PHP-7.3:
  Fixed bug #77339 (__callStatic may get incorrect arguments)
This commit is contained in:
Dmitry Stogov 2018-12-24 13:25:24 +03:00
commit 773ed62555
2 changed files with 41 additions and 0 deletions

33
Zend/tests/bug77339.phpt Normal file
View File

@ -0,0 +1,33 @@
--TEST--
Bug #77339 (__callStatic may get incorrect arguments)
--FILE--
<?php
class Foo
{
static function __callStatic($name, $arguments) {
if ($name === 'get') {
if (!isset($arguments[0])) {
var_dump(['getSomeWhat']);
var_dump($arguments);
exit;
}
}
echo "OK\n";
}
protected function get ($key) {
echo "BUG!!!\n";
}
}
class Bar
{
static function __callStatic($name, $arguments) {
echo Foo::get('getSomeWhat');
}
}
Bar::someUndefinedStaticFunction();
?>
--EXPECT--
OK

View File

@ -4055,6 +4055,14 @@ void zend_compile_static_call(znode *result, zend_ast *ast, uint32_t type) /* {{
if (ce) {
zend_string *lcname = Z_STR_P(CT_CONSTANT(opline->op2) + 1);
fbc = zend_hash_find_ptr(&ce->function_table, lcname);
if (fbc && !(fbc->common.fn_flags & ZEND_ACC_PUBLIC)) {
if (ce != CG(active_class_entry)
&&((fbc->common.fn_flags & ZEND_ACC_PRIVATE)
|| !zend_check_protected(zend_get_function_root_class(fbc), CG(active_class_entry)))) {
/* incompatibe function */
fbc = NULL;
}
}
}
}