From: Marcus Boerger Date: Mon, 3 Apr 2006 19:52:02 +0000 (+0000) Subject: - Fix issue related to #36941 (when referencing itself) X-Git-Tag: RELEASE_1_3~160 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=091360caa17167f740e904185a1dc6e59b2d35b8;p=php - Fix issue related to #36941 (when referencing itself) --- diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index b36a92d071..3f0181dae4 100755 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -73,7 +73,9 @@ typedef struct _spl_array_object { } spl_array_object; static inline HashTable *spl_array_get_hash_table(spl_array_object* intern, int check_std_props TSRMLS_DC) { - if ((intern->ar_flags & SPL_ARRAY_USE_OTHER) && (check_std_props == 0 || (intern->ar_flags & SPL_ARRAY_STD_PROP_LIST) == 0)) { + if ((intern->ar_flags & SPL_ARRAY_IS_SELF) != 0) { + return intern->std.properties; + } else if ((intern->ar_flags & SPL_ARRAY_USE_OTHER) && (check_std_props == 0 || (intern->ar_flags & SPL_ARRAY_STD_PROP_LIST) == 0)) { spl_array_object *other = (spl_array_object*)zend_object_store_get_object(intern->array TSRMLS_CC); return spl_array_get_hash_table(other, check_std_props TSRMLS_CC); } else if ((intern->ar_flags & ((check_std_props ? SPL_ARRAY_STD_PROP_LIST : 0) | SPL_ARRAY_IS_SELF)) != 0) { diff --git a/ext/spl/tests/array_022.phpt b/ext/spl/tests/array_022.phpt new file mode 100755 index 0000000000..d1eafd677c --- /dev/null +++ b/ext/spl/tests/array_022.phpt @@ -0,0 +1,94 @@ +--TEST-- +SPL: ArrayObject/Iterator and reference to self +--FILE-- +==ArrayObject=== + +==ArrayIterator=== + +===DONE=== +--EXPECTF-- +==ArrayObject=== +object(MyArrayObject)#%d (1) { + ["bar"]=> + string(3) "baz" +} +object(MyArrayObject)#%d (2) { + ["bar"]=> + string(3) "baz" + ["baz"]=> + string(3) "Foo" +} +==ArrayIterator=== +object(MyArrayIterator)#%d (1) { + ["bar"]=> + string(3) "baz" +} +object(MyArrayIterator)#%d (2) { + ["bar"]=> + string(3) "baz" + ["baz"]=> + string(3) "Foo" +} +===DONE=== +--UEXPECTF-- +==ArrayObject=== +object(MyArrayObject)#%d (1) { + [u"bar"]=> + unicode(3) "baz" +} +object(MyArrayObject)#%d (2) { + [u"bar"]=> + unicode(3) "baz" + [u"baz"]=> + unicode(3) "Foo" +} +==ArrayIterator=== +object(MyArrayIterator)#%d (1) { + [u"bar"]=> + unicode(3) "baz" +} +object(MyArrayIterator)#%d (2) { + [u"bar"]=> + unicode(3) "baz" + [u"baz"]=> + unicode(3) "Foo" +} +===DONE===