tony2001 Wed Jul 11 22:06:54 2007 UTC
Added files: (Branch: PHP_5_2)
/php-src/ext/reflection/tests bug41884.phpt
Modified files:
/php-src NEWS
/php-src/ext/reflection php_reflection.c
Log:
MFH
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.828&r2=1.2027.2.547.2.829&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.828 php-src/NEWS:1.2027.2.547.2.829
--- php-src/NEWS:1.2027.2.547.2.828 Wed Jul 11 17:36:55 2007
+++ php-src/NEWS Wed Jul 11 22:06:54 2007
@@ -6,7 +6,7 @@
- Upgraded PCRE to version 7.2 (Nuno)
- Updated timezone database to version 2007.6. (Derick)
-- Improced openssl_x509_parse() to return extensions in readable form. (Dmitry)
+- Improved openssl_x509_parse() to return extensions in readable form. (Dmitry)
- Improved fix for MOPB-03-2007. (Ilia)
- Corrected fix for CVE-2007-2872. (Ilia)
- Enabled statement cache for non-persistent OCI8 connections.
@@ -32,7 +32,10 @@
- Added CURLOPT_PRIVATE & CURLINFO_PRIVATE constants.
(Andrey A. Belashkov, Tony)
-- Fixed crash in OpenSSL extension because of non-strin passphrase. (Dmitry)
+- Implemented FR #41884 (ReflectionClass::getDefaultProperties() does not
handle
+ static attributes). (Tony)
+
+- Fixed crash in OpenSSL extension because of non-string passphrase. (Dmitry)
- Fixed var_export() to use the new H modifier so that it can generate
parseable PHP code for floats, independent of the locale. (Derick)
- Fixed regression introduced by the fix for the libgd bug #74. (Pierre)
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/php_reflection.c?r1=1.164.2.33.2.40&r2=1.164.2.33.2.41&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.40
php-src/ext/reflection/php_reflection.c:1.164.2.33.2.41
--- php-src/ext/reflection/php_reflection.c:1.164.2.33.2.40 Wed Jul 11
13:27:49 2007
+++ php-src/ext/reflection/php_reflection.c Wed Jul 11 22:06:54 2007
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_reflection.c,v 1.164.2.33.2.40 2007/07/11 13:27:49 tony2001 Exp $
*/
+/* $Id: php_reflection.c,v 1.164.2.33.2.41 2007/07/11 22:06:54 tony2001 Exp $
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -2804,7 +2804,8 @@
{
reflection_object *intern;
zend_class_entry *ce;
- int count;
+ int count, i;
+ HashTable *ht_list[3];
METHOD_NOTSTATIC_NUMPARAMS(reflection_class_ptr, 0);
GET_REFLECTION_OBJECT_PTR(ce);
@@ -2812,33 +2813,40 @@
zend_update_class_constants(ce TSRMLS_CC);
- count = zend_hash_num_elements(&ce->default_properties);
- if (count > 0) {
- HashPosition pos;
- zval **prop;
+ ht_list[0] = CE_STATIC_MEMBERS(ce);
+ ht_list[1] = &ce->default_properties;
+ ht_list[2] = NULL;
- zend_hash_internal_pointer_reset_ex(&ce->default_properties,
&pos);
- while (zend_hash_get_current_data_ex(&ce->default_properties,
(void **) &prop, &pos) == SUCCESS) {
- char *key, *class_name, *prop_name;
- uint key_len;
- ulong num_index;
- zval *prop_copy;
+ for (i = 0; ht_list[i] != NULL; i++) {
- zend_hash_get_current_key_ex(&ce->default_properties,
&key, &key_len, &num_index, 0, &pos);
- zend_hash_move_forward_ex(&ce->default_properties,
&pos);
- zend_unmangle_property_name(key, key_len-1,
&class_name, &prop_name);
- if (class_name && class_name[0] != '*' &&
strcmp(class_name, ce->name)) {
- /* filter privates from base classes */
- continue;
- }
+ count = zend_hash_num_elements(ht_list[i]);
+ if (count > 0) {
+ HashPosition pos;
+ zval **prop;
- /* copy: enforce read only access */
- ALLOC_ZVAL(prop_copy);
- *prop_copy = **prop;
- zval_copy_ctor(prop_copy);
- INIT_PZVAL(prop_copy);
+ zend_hash_internal_pointer_reset_ex(ht_list[i], &pos);
+ while (zend_hash_get_current_data_ex(ht_list[i], (void
**) &prop, &pos) == SUCCESS) {
+ char *key, *class_name, *prop_name;
+ uint key_len;
+ ulong num_index;
+ zval *prop_copy;
+
+ zend_hash_get_current_key_ex(ht_list[i], &key,
&key_len, &num_index, 0, &pos);
+ zend_hash_move_forward_ex(ht_list[i], &pos);
+ zend_unmangle_property_name(key, key_len-1,
&class_name, &prop_name);
+ if (class_name && class_name[0] != '*' &&
strcmp(class_name, ce->name)) {
+ /* filter privates from base classes */
+ continue;
+ }
- add_assoc_zval(return_value, prop_name, prop_copy);
+ /* copy: enforce read only access */
+ ALLOC_ZVAL(prop_copy);
+ *prop_copy = **prop;
+ zval_copy_ctor(prop_copy);
+ INIT_PZVAL(prop_copy);
+
+ add_assoc_zval(return_value, prop_name,
prop_copy);
+ }
}
}
}
@@ -4878,7 +4886,7 @@
php_info_print_table_start();
php_info_print_table_header(2, "Reflection", "enabled");
- php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v
1.164.2.33.2.40 2007/07/11 13:27:49 tony2001 Exp $");
+ php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v
1.164.2.33.2.41 2007/07/11 22:06:54 tony2001 Exp $");
php_info_print_table_end();
} /* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/bug41884.phpt?view=markup&rev=1.1
Index: php-src/ext/reflection/tests/bug41884.phpt
+++ php-src/ext/reflection/tests/bug41884.phpt
--TEST--
Bug #41884 (ReflectionClass::getDefaultProperties() does not handle static
attributes)
--FILE--
<?php
class Foo
{
protected static $fooStatic = 'foo';
protected $foo = 'foo';
}
$class = new ReflectionClass('Foo');
var_dump($class->getDefaultProperties());
echo "Done\n";
?>
--EXPECTF--
array(2) {
["fooStatic"]=>
string(3) "foo"
["foo"]=>
string(3) "foo"
}
Done
--UEXPECTF--
array(2) {
[u"fooStatic"]=>
unicode(3) "foo"
[u"foo"]=>
unicode(3) "foo"
}
Done
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php