diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-12-13 16:38:24 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-12-13 16:38:24 +0100 |
commit | 7e9e0937f3a4557bf03ee5a3e7a546b266781eb4 (patch) | |
tree | 7906568c1c5a55e01146fd2e56956702c0a0c1d9 /Zend | |
parent | 0f2cdbf214efd98b4bdaf5ca41728faf00e7c037 (diff) | |
parent | 621598eaa8063a9e76447e07f6f3c30a8baca1e0 (diff) | |
download | php-git-7e9e0937f3a4557bf03ee5a3e7a546b266781eb4.tar.gz |
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
Fixed bug #78921
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/tests/bug78921.phpt | 36 | ||||
-rw-r--r-- | Zend/zend_execute_API.c | 4 |
2 files changed, 40 insertions, 0 deletions
diff --git a/Zend/tests/bug78921.phpt b/Zend/tests/bug78921.phpt new file mode 100644 index 0000000000..a368788081 --- /dev/null +++ b/Zend/tests/bug78921.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #78921: When Reflection triggers class load, property visibility is incorrect +--FILE-- +<?php + +spl_autoload_register(function($className) { + if ($className == 'PrivateStatic') { + class PrivateStatic + { + const SOME_CONST = 13; + private static $privateStaticVarArray = ['a', 'b', 'c']; + private static $otherStatic; + public static function init() + { + self::$otherStatic = self::$privateStaticVarArray; + } + } + PrivateStatic::init(); + } +}); + +class OtherClass +{ + const MY_CONST = PrivateStatic::SOME_CONST; + public static $prop = 'my property'; +} + +$reflectionClass = new ReflectionClass('OtherClass'); +$reflectionProperty = $reflectionClass->getProperty('prop'); +$reflectionProperty->setAccessible(true); +$value = $reflectionProperty->getValue(); +echo "Value is $value\n"; + +?> +--EXPECT-- +Value is my property diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index d9e0d0a8aa..e1001062e5 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -890,6 +890,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string * zend_string *lc_name; zend_fcall_info fcall_info; zend_fcall_info_cache fcall_cache; + zend_class_entry *orig_fake_scope; if (key) { lc_name = key; @@ -986,11 +987,14 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string * fcall_cache.called_scope = NULL; fcall_cache.object = NULL; + orig_fake_scope = EG(fake_scope); + EG(fake_scope) = NULL; zend_exception_save(); if ((zend_call_function(&fcall_info, &fcall_cache) == SUCCESS) && !EG(exception)) { ce = zend_hash_find_ptr(EG(class_table), lc_name); } zend_exception_restore(); + EG(fake_scope) = orig_fake_scope; zval_ptr_dtor(&args[0]); zval_ptr_dtor_str(&fcall_info.function_name); |