sebastian Sat Apr 4 14:35:29 2009 UTC
Modified files:
/php-src/ext/reflection php_reflection.c
/php-src/ext/reflection/tests reflectionProperty_setAccessible.phpt
Log:
Fix issue reported by Roman Borschel.
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/php_reflection.c?r1=1.341&r2=1.342&diff_format=u
Index: php-src/ext/reflection/php_reflection.c
diff -u php-src/ext/reflection/php_reflection.c:1.341
php-src/ext/reflection/php_reflection.c:1.342
--- php-src/ext/reflection/php_reflection.c:1.341 Thu Mar 26 20:01:57 2009
+++ php-src/ext/reflection/php_reflection.c Sat Apr 4 14:35:28 2009
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_reflection.c,v 1.341 2009/03/26 20:01:57 felipe Exp $ */
+/* $Id: php_reflection.c,v 1.342 2009/04/04 14:35:28 sebastian Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -4726,7 +4726,7 @@
}
zend_u_unmangle_property_name(IS_UNICODE, ref->prop.name,
ref->prop.name_length, &class_name, &prop_name);
prop_name_len = u_strlen(prop_name.u);
- member_p = zend_u_read_property(Z_OBJCE_P(object), object,
IS_UNICODE, prop_name, prop_name_len, 1 TSRMLS_CC);
+ member_p = zend_u_read_property(ref->ce, object, IS_UNICODE,
prop_name, prop_name_len, 1 TSRMLS_CC);
*return_value= *member_p;
zval_copy_ctor(return_value);
INIT_PZVAL(return_value);
@@ -4807,7 +4807,7 @@
}
zend_u_unmangle_property_name(IS_UNICODE, ref->prop.name,
ref->prop.name_length, &class_name, &prop_name);
prop_name_len = u_strlen(prop_name.u);
- zend_u_update_property(Z_OBJCE_P(object), object, IS_UNICODE,
prop_name, prop_name_len, value TSRMLS_CC);
+ zend_u_update_property(ref->ce, object, IS_UNICODE, prop_name,
prop_name_len, value TSRMLS_CC);
}
}
/* }}} */
@@ -5680,7 +5680,7 @@
php_info_print_table_start();
php_info_print_table_header(2, "Reflection", "enabled");
- php_info_print_table_row(2, "Version", "$Revision: 1.341 $");
+ php_info_print_table_row(2, "Version", "$Revision: 1.342 $");
php_info_print_table_end();
} /* }}} */
@@ -5694,7 +5694,7 @@
NULL,
NULL,
PHP_MINFO(reflection),
- "$Revision: 1.341 $",
+ "$Revision: 1.342 $",
STANDARD_MODULE_PROPERTIES
}; /* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionProperty_setAccessible.phpt?r1=1.3&r2=1.4&diff_format=u
Index: php-src/ext/reflection/tests/reflectionProperty_setAccessible.phpt
diff -u php-src/ext/reflection/tests/reflectionProperty_setAccessible.phpt:1.3
php-src/ext/reflection/tests/reflectionProperty_setAccessible.phpt:1.4
--- php-src/ext/reflection/tests/reflectionProperty_setAccessible.phpt:1.3
Sat Nov 29 15:58:30 2008
+++ php-src/ext/reflection/tests/reflectionProperty_setAccessible.phpt Sat Apr
4 14:35:28 2009
@@ -9,6 +9,8 @@
private static $privateStatic = 'd';
}
+class B extends A {}
+
$a = new A;
$protected = new ReflectionProperty($a, 'protected');
$protectedStatic = new ReflectionProperty('A', 'protectedStatic');
@@ -66,6 +68,52 @@
var_dump($protectedStatic->getValue());
var_dump($private->getValue($a));
var_dump($privateStatic->getValue());
+
+$a = new A;
+$b = new B;
+$protected = new ReflectionProperty($b, 'protected');
+$protectedStatic = new ReflectionProperty('B', 'protectedStatic');
+$private = new ReflectionProperty($a, 'private');
+
+try {
+ var_dump($protected->getValue($b));
+}
+
+catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+try {
+ var_dump($protectedStatic->getValue());
+}
+
+catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+try {
+ var_dump($private->getValue($b));
+}
+
+catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+$protected->setAccessible(TRUE);
+$protectedStatic->setAccessible(TRUE);
+$private->setAccessible(TRUE);
+
+var_dump($protected->getValue($b));
+var_dump($protectedStatic->getValue());
+var_dump($private->getValue($b));
+
+$protected->setValue($b, 'e');
+$protectedStatic->setValue('f');
+$private->setValue($b, 'g');
+
+var_dump($protected->getValue($b));
+var_dump($protectedStatic->getValue());
+var_dump($private->getValue($b));
?>
--EXPECT--
unicode(44) "Cannot access non-public member A::protected"
@@ -80,3 +128,12 @@
unicode(1) "f"
unicode(1) "g"
unicode(1) "h"
+unicode(44) "Cannot access non-public member B::protected"
+unicode(50) "Cannot access non-public member B::protectedStatic"
+unicode(42) "Cannot access non-public member A::private"
+unicode(1) "a"
+unicode(1) "f"
+unicode(1) "c"
+unicode(1) "e"
+unicode(1) "f"
+unicode(1) "g"
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php