diff options
author | Dmitry Stogov <dmitry@zend.com> | 2019-11-25 14:10:53 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2019-11-25 14:10:53 +0300 |
commit | 0f2b6ece4ea2c4fe5173a40539aabd3ecdbc29f8 (patch) | |
tree | 8877deea7d79c6431b4be7ad1c69d498690b1c43 | |
parent | 1de312d9b19fd024b90d52adc835f462ec12cb17 (diff) | |
parent | 2ebf530946354e39e3d3df8f96813a06f495f930 (diff) | |
download | php-git-0f2b6ece4ea2c4fe5173a40539aabd3ecdbc29f8.tar.gz |
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
-rw-r--r-- | Zend/tests/bug78868.phpt | 33 | ||||
-rw-r--r-- | Zend/zend_API.c | 6 |
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; |