diff options
-rw-r--r-- | ext/spl/spl_array.c | 3 | ||||
-rw-r--r-- | ext/spl/tests/ArrayObject_clone_other_std_props.phpt | 23 |
2 files changed, 25 insertions, 1 deletions
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 83c1f288ff..d3603a3b32 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -167,7 +167,8 @@ static zend_object *spl_array_object_new_ex(zend_class_entry *class_type, zval * if (other->ar_flags & SPL_ARRAY_IS_SELF) { ZVAL_UNDEF(&intern->array); } else if (Z_OBJ_HT_P(orig) == &spl_handler_ArrayObject) { - ZVAL_ARR(&intern->array, zend_array_dup(HASH_OF(&other->array))); + ZVAL_ARR(&intern->array, + zend_array_dup(spl_array_get_hash_table(&other->array, 0))); } else { ZEND_ASSERT(Z_OBJ_HT_P(orig) == &spl_handler_ArrayIterator); ZVAL_COPY(&intern->array, orig); diff --git a/ext/spl/tests/ArrayObject_clone_other_std_props.phpt b/ext/spl/tests/ArrayObject_clone_other_std_props.phpt new file mode 100644 index 0000000000..688954c3d7 --- /dev/null +++ b/ext/spl/tests/ArrayObject_clone_other_std_props.phpt @@ -0,0 +1,23 @@ +--TEST-- +Clone ArrayObject using other with STD_PROP_LIST +--FILE-- +<?php + +$a = new ArrayObject([1, 2, 3], ArrayObject::STD_PROP_LIST); +$b = new ArrayObject($a); +$c = clone $b; +var_dump($c); + +?> +--EXPECT-- +object(ArrayObject)#3 (1) { + ["storage":"ArrayObject":private]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} |