Skip to content

Commit 23de434

Browse files
author
Ilia Alshanetsky
committed
MFB: Improved fix for bug #38132
1 parent 87182b1 commit 23de434

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

ext/reflection/php_reflection.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2643,17 +2643,36 @@ ZEND_METHOD(reflection_class, __construct)
26432643
Returns an associative array containing all static property values of the class */
26442644
ZEND_METHOD(reflection_class, getStaticProperties)
26452645
{
2646-
zval *tmp_copy;
26472646
reflection_object *intern;
26482647
zend_class_entry *ce;
2648+
HashPosition pos;
2649+
zval **value;
26492650

26502651
METHOD_NOTSTATIC_NUMPARAMS(reflection_class_ptr, 0);
26512652
GET_REFLECTION_OBJECT_PTR(ce);
26522653

26532654
zend_update_class_constants(ce TSRMLS_CC);
26542655

26552656
array_init(return_value);
2656-
zend_hash_copy(Z_ARRVAL_P(return_value), CE_STATIC_MEMBERS(ce), (copy_ctor_func_t) zval_add_ref, (void *) &tmp_copy, sizeof(zval *));
2657+
zend_hash_internal_pointer_reset_ex(CE_STATIC_MEMBERS(ce), &pos);
2658+
2659+
while (zend_hash_get_current_data_ex(CE_STATIC_MEMBERS(ce), (void **) &value, &pos) == SUCCESS) {
2660+
uint key_len;
2661+
zstr key;
2662+
ulong num_index;
2663+
2664+
if (zend_hash_get_current_key_ex(CE_STATIC_MEMBERS(ce), &key, &key_len, &num_index, 0, &pos) != FAILURE) {
2665+
zstr prop_name, class_name;
2666+
int prop_name_len = UG(unicode) ? u_strlen(prop_name.u) : strlen(prop_name.s);
2667+
2668+
zend_u_unmangle_property_name(UG(unicode)?IS_UNICODE:IS_STRING, key, key_len-1, &class_name, &prop_name);
2669+
2670+
zval_add_ref(value);
2671+
2672+
zend_u_hash_update(Z_ARRVAL_P(return_value), UG(unicode)?IS_UNICODE:IS_STRING, prop_name, prop_name_len, value, sizeof(zval *), NULL);
2673+
}
2674+
zend_hash_move_forward_ex(CE_STATIC_MEMBERS(ce), &pos);
2675+
}
26572676
}
26582677
/* }}} */
26592678

0 commit comments

Comments
 (0)