1
0
mirror of https://github.com/php/php-src.git synced 2026-04-09 17:13:31 +02:00

Merge branch 'PHP-7.4'

* PHP-7.4:
  Fixed bug #78868 (Calling __autoload() with incorrect EG(fake_scope) value)
  Consolidate NEWS for 7.4.0 release
  WIP: Merge NEWS
This commit is contained in:
Dmitry Stogov
2019-11-25 14:10:53 +03:00
2 changed files with 39 additions and 0 deletions

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

@@ -0,0 +1,33 @@
--TEST--
Bug #78868: Calling __autoload() with incorrect EG(fake_scope) value
--FILE--
<?php
class C {
private $private = 1;
function foo() {
$this->private++; //fails with EG(fake_scope) != NULL && EG(fake_scope) != "C"
}
}
class A {
static $foo = B::foo; //not resolved on include()
}
function main_autoload($class_name) {
$c = new C;
$c->foo();
//doesn't affect the error
eval("class B {const foo = 1;}");
}
spl_autoload_register('main_autoload', false);
$classA = new ReflectionClass("A");
$props = $classA->getProperties();
$props[0]->setValue(2); //causes constant resolving, which runs autoload, all with EG(fake_scope) == "A"
echo "OK\n";
?>
--EXPECT--
OK

View File

@@ -3995,6 +3995,12 @@ ZEND_API int zend_update_static_property_ex(zend_class_entry *scope, zend_string
zend_property_info *prop_info;
zend_class_entry *old_scope = EG(fake_scope);
if (UNEXPECTED(!(scope->ce_flags & ZEND_ACC_CONSTANTS_UPDATED))) {
if (UNEXPECTED(zend_update_class_constants(scope)) != SUCCESS) {
return FAILURE;
}
}
EG(fake_scope) = scope;
property = zend_std_get_static_property_with_info(scope, name, BP_VAR_W, &prop_info);
EG(fake_scope) = old_scope;