mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
commit
7e9e0937f3
2 changed files with 40 additions and 0 deletions
36
Zend/tests/bug78921.phpt
Normal file
36
Zend/tests/bug78921.phpt
Normal file
|
@ -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
|
|
@ -890,6 +890,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *
|
||||||
zend_string *lc_name;
|
zend_string *lc_name;
|
||||||
zend_fcall_info fcall_info;
|
zend_fcall_info fcall_info;
|
||||||
zend_fcall_info_cache fcall_cache;
|
zend_fcall_info_cache fcall_cache;
|
||||||
|
zend_class_entry *orig_fake_scope;
|
||||||
|
|
||||||
if (key) {
|
if (key) {
|
||||||
lc_name = 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.called_scope = NULL;
|
||||||
fcall_cache.object = NULL;
|
fcall_cache.object = NULL;
|
||||||
|
|
||||||
|
orig_fake_scope = EG(fake_scope);
|
||||||
|
EG(fake_scope) = NULL;
|
||||||
zend_exception_save();
|
zend_exception_save();
|
||||||
if ((zend_call_function(&fcall_info, &fcall_cache) == SUCCESS) && !EG(exception)) {
|
if ((zend_call_function(&fcall_info, &fcall_cache) == SUCCESS) && !EG(exception)) {
|
||||||
ce = zend_hash_find_ptr(EG(class_table), lc_name);
|
ce = zend_hash_find_ptr(EG(class_table), lc_name);
|
||||||
}
|
}
|
||||||
zend_exception_restore();
|
zend_exception_restore();
|
||||||
|
EG(fake_scope) = orig_fake_scope;
|
||||||
|
|
||||||
zval_ptr_dtor(&args[0]);
|
zval_ptr_dtor(&args[0]);
|
||||||
zval_ptr_dtor_str(&fcall_info.function_name);
|
zval_ptr_dtor_str(&fcall_info.function_name);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue