Skip to content

Commit 2ebf530

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fixed bug #78868 (Calling __autoload() with incorrect EG(fake_scope) value)
2 parents 71d42dc + bb30fe9 commit 2ebf530

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ PHP NEWS
66
- Core:
77
. Fixed bug #78810 (RW fetches do not throw "uninitialized property"
88
exception). (Nikita)
9+
. Fixed bug #78868 (Calling __autoload() with incorrect EG(fake_scope) value).
10+
(Antony Dovgal, Dmitry)
911

1012
- GD:
1113
. Fixed bug #78849 (GD build broken with -D SIGNED_COMPARE_SLOW). (cmb)

Zend/tests/bug78868.phpt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Bug #78868: Calling __autoload() with incorrect EG(fake_scope) value
3+
--FILE--
4+
<?php
5+
class C {
6+
private $private = 1;
7+
8+
function foo() {
9+
$this->private++; //fails with EG(fake_scope) != NULL && EG(fake_scope) != "C"
10+
}
11+
}
12+
13+
class A {
14+
static $foo = B::foo; //not resolved on include()
15+
}
16+
17+
function main_autoload($class_name) {
18+
$c = new C;
19+
$c->foo();
20+
//doesn't affect the error
21+
eval("class B {const foo = 1;}");
22+
}
23+
24+
spl_autoload_register('main_autoload', false);
25+
26+
$classA = new ReflectionClass("A");
27+
$props = $classA->getProperties();
28+
$props[0]->setValue(2); //causes constant resolving, which runs autoload, all with EG(fake_scope) == "A"
29+
30+
echo "OK\n";
31+
?>
32+
--EXPECT--
33+
OK

Zend/zend_API.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4206,6 +4206,12 @@ ZEND_API int zend_update_static_property_ex(zend_class_entry *scope, zend_string
42064206
zend_property_info *prop_info;
42074207
zend_class_entry *old_scope = EG(fake_scope);
42084208

4209+
if (UNEXPECTED(!(scope->ce_flags & ZEND_ACC_CONSTANTS_UPDATED))) {
4210+
if (UNEXPECTED(zend_update_class_constants(scope)) != SUCCESS) {
4211+
return FAILURE;
4212+
}
4213+
}
4214+
42094215
EG(fake_scope) = scope;
42104216
property = zend_std_get_static_property_with_info(scope, name, BP_VAR_W, &prop_info);
42114217
EG(fake_scope) = old_scope;

0 commit comments

Comments
 (0)