sebastian Sat Apr 4 14:36:23 2009 UTC
Modified files: (Branch: PHP_5_3)
/php-src/ext/reflection php_reflection.c
/php-src/ext/reflection/tests reflectionProperty_setAccessible.phpt
/php-src NEWS
Log:
MFH: Fix issue reported by Roman Borschel.
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/php_reflection.c?r1=1.164.2.33.2.45.2.54&r2=1.164.2.33.2.45.2.55&diff_format=u
Index: php-src/ext/reflection/php_reflection.c
diff -u php-src/ext/reflection/php_reflection.c:1.164.2.33.2.45.2.54
php-src/ext/reflection/php_reflection.c:1.164.2.33.2.45.2.55
--- php-src/ext/reflection/php_reflection.c:1.164.2.33.2.45.2.54 Thu Apr
2 21:30:09 2009
+++ php-src/ext/reflection/php_reflection.c Sat Apr 4 14:36:22 2009
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_reflection.c,v 1.164.2.33.2.45.2.54 2009/04/02 21:30:09 iliaa Exp
$ */
+/* $Id: php_reflection.c,v 1.164.2.33.2.45.2.55 2009/04/04 14:36:22 sebastian
Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -4491,7 +4491,7 @@
return;
}
zend_unmangle_property_name(ref->prop.name,
ref->prop.name_length, &class_name, &prop_name);
- member_p = zend_read_property(Z_OBJCE_P(object), object,
prop_name, strlen(prop_name), 1 TSRMLS_CC);
+ member_p = zend_read_property(ref->ce, object, prop_name,
strlen(prop_name), 1 TSRMLS_CC);
*return_value= *member_p;
zval_copy_ctor(return_value);
INIT_PZVAL(return_value);
@@ -4569,7 +4569,7 @@
return;
}
zend_unmangle_property_name(ref->prop.name,
ref->prop.name_length, &class_name, &prop_name);
- zend_update_property(Z_OBJCE_P(object), object, prop_name,
strlen(prop_name), value TSRMLS_CC);
+ zend_update_property(ref->ce, object, prop_name,
strlen(prop_name), value TSRMLS_CC);
}
}
/* }}} */
@@ -5437,7 +5437,7 @@
php_info_print_table_start();
php_info_print_table_header(2, "Reflection", "enabled");
- php_info_print_table_row(2, "Version", "$Revision: 1.164.2.33.2.45.2.54
$");
+ php_info_print_table_row(2, "Version", "$Revision: 1.164.2.33.2.45.2.55
$");
php_info_print_table_end();
} /* }}} */
@@ -5451,7 +5451,7 @@
NULL,
NULL,
PHP_MINFO(reflection),
- "$Revision: 1.164.2.33.2.45.2.54 $",
+ "$Revision: 1.164.2.33.2.45.2.55 $",
STANDARD_MODULE_PROPERTIES
}; /* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionProperty_setAccessible.phpt?r1=1.1.2.4&r2=1.1.2.5&diff_format=u
Index: php-src/ext/reflection/tests/reflectionProperty_setAccessible.phpt
diff -u
php-src/ext/reflection/tests/reflectionProperty_setAccessible.phpt:1.1.2.4
php-src/ext/reflection/tests/reflectionProperty_setAccessible.phpt:1.1.2.5
--- php-src/ext/reflection/tests/reflectionProperty_setAccessible.phpt:1.1.2.4
Sat Nov 29 15:58:54 2008
+++ php-src/ext/reflection/tests/reflectionProperty_setAccessible.phpt Sat Apr
4 14:36:23 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--
string(44) "Cannot access non-public member A::protected"
@@ -80,3 +128,12 @@
string(1) "f"
string(1) "g"
string(1) "h"
+string(44) "Cannot access non-public member B::protected"
+string(50) "Cannot access non-public member B::protectedStatic"
+string(42) "Cannot access non-public member A::private"
+string(1) "a"
+string(1) "f"
+string(1) "c"
+string(1) "e"
+string(1) "f"
+string(1) "g"
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.551&r2=1.2027.2.547.2.965.2.552&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.965.2.551
php-src/NEWS:1.2027.2.547.2.965.2.552
--- php-src/NEWS:1.2027.2.547.2.965.2.551 Thu Apr 2 16:41:23 2009
+++ php-src/NEWS Sat Apr 4 14:36:23 2009
@@ -29,6 +29,8 @@
update). (Matteo)
- Fixed bug #42362 (HTTP status codes 204 and 304 should not be gzipped).
(Scott, Edward Z. Yang)
+- Fixed an issue with ReflectionProperty::setAccessible().
+ (Sebastian, Roman Borschel)
24 Mar 2009, PHP 5.3.0 RC 1
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php