]> granicus.if.org Git - php/commitdiff
MFB: Improved fix for bug #38132
authorIlia Alshanetsky <iliaa@php.net>
Thu, 27 Jul 2006 00:22:07 +0000 (00:22 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 27 Jul 2006 00:22:07 +0000 (00:22 +0000)
ext/reflection/php_reflection.c

index 084c82930ffed3e2dcda083049c0707d6dc5f5d5..6c8045b1fc2767fd5f22e285be08b5b6a4ffcd3a 100644 (file)
@@ -2643,9 +2643,10 @@ ZEND_METHOD(reflection_class, __construct)
    Returns an associative array containing all static property values of the class */
 ZEND_METHOD(reflection_class, getStaticProperties)
 {
-       zval *tmp_copy;
        reflection_object *intern;
        zend_class_entry *ce;
+        HashPosition pos;
+        zval **value;
        
        METHOD_NOTSTATIC_NUMPARAMS(reflection_class_ptr, 0);    
        GET_REFLECTION_OBJECT_PTR(ce);
@@ -2653,7 +2654,25 @@ ZEND_METHOD(reflection_class, getStaticProperties)
        zend_update_class_constants(ce TSRMLS_CC);
 
        array_init(return_value);
-       zend_hash_copy(Z_ARRVAL_P(return_value), CE_STATIC_MEMBERS(ce), (copy_ctor_func_t) zval_add_ref, (void *) &tmp_copy, sizeof(zval *));
+       zend_hash_internal_pointer_reset_ex(CE_STATIC_MEMBERS(ce), &pos);
+
+       while (zend_hash_get_current_data_ex(CE_STATIC_MEMBERS(ce), (void **) &value, &pos) == SUCCESS) {
+               uint key_len;
+               zstr key;
+               ulong num_index;
+
+               if (zend_hash_get_current_key_ex(CE_STATIC_MEMBERS(ce), &key, &key_len, &num_index, 0, &pos) != FAILURE) {
+                       zstr prop_name, class_name;
+                       int prop_name_len = UG(unicode) ? u_strlen(prop_name.u) : strlen(prop_name.s);
+
+                       zend_u_unmangle_property_name(UG(unicode)?IS_UNICODE:IS_STRING, key, key_len-1, &class_name, &prop_name);
+
+                       zval_add_ref(value);
+
+                       zend_u_hash_update(Z_ARRVAL_P(return_value), UG(unicode)?IS_UNICODE:IS_STRING, prop_name, prop_name_len, value, sizeof(zval *), NULL);
+               }
+               zend_hash_move_forward_ex(CE_STATIC_MEMBERS(ce), &pos);
+       }
 }
 /* }}} */