Skip to content

Commit

Permalink
Merge branch 'PHP-7.4'
Browse files Browse the repository at this point in the history
* PHP-7.4:
  Fixed bug #78868 (Calling __autoload() with incorrect EG(fake_scope) value)
  Consolidate NEWS for 7.4.0 release
  WIP: Merge NEWS
  • Loading branch information
dstogov committed Nov 25, 2019
2 parents 1de312d + 2ebf530 commit 0f2b6ec
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Zend/tests/bug78868.phpt
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0f2b6ec

Please sign in to comment.