summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/tests/bug78868.phpt33
-rw-r--r--Zend/zend_API.c6
2 files changed, 39 insertions, 0 deletions
diff --git a/Zend/tests/bug78868.phpt b/Zend/tests/bug78868.phpt
new file mode 100644
index 0000000000..172af2a930
--- /dev/null
+++ b/Zend/tests/bug78868.phpt
@@ -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
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 87cfd5f139..8868090b1b 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -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;