From: Nikita Popov Date: Sun, 20 Mar 2016 16:46:12 +0000 (+0100) Subject: Fixed bug #67582 X-Git-Tag: php-5.6.21RC1~30 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cc3cdd00578006a5684e6dfaf81532a13326b9fe;p=php Fixed bug #67582 --- diff --git a/NEWS b/NEWS index c2cca344e1..cf7edaf931 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,10 @@ PHP NEWS . Fixed bug #71820 (pg_fetch_object binds parameters before call constructor). (Anatol) +- SPL: + . Fixed bug #67582 (Cloned SplObjectStorage with overwritten getHash fails + offsetExists()). (Nikita) + - Standard: . Fixed bug #71840 (Unserialize accepts wrongly data). (Ryat, Laruence) diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c index 08cf66a67b..fb0b29fccd 100644 --- a/ext/spl/spl_observer.c +++ b/ext/spl/spl_observer.c @@ -275,11 +275,6 @@ static zend_object_value spl_object_storage_new_ex(zend_class_entry *class_type, retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) spl_SplOjectStorage_free_storage, NULL TSRMLS_CC); retval.handlers = &spl_handler_SplObjectStorage; - if (orig) { - spl_SplObjectStorage *other = (spl_SplObjectStorage*)zend_object_store_get_object(orig TSRMLS_CC); - spl_object_storage_addall(intern, orig, other TSRMLS_CC); - } - while (parent) { if (parent == spl_ce_SplObjectStorage) { if (class_type != spl_ce_SplObjectStorage) { @@ -294,6 +289,11 @@ static zend_object_value spl_object_storage_new_ex(zend_class_entry *class_type, parent = parent->parent; } + if (orig) { + spl_SplObjectStorage *other = (spl_SplObjectStorage*)zend_object_store_get_object(orig TSRMLS_CC); + spl_object_storage_addall(intern, orig, other TSRMLS_CC); + } + return retval; } /* }}} */ diff --git a/ext/spl/tests/bug67582.phpt b/ext/spl/tests/bug67582.phpt new file mode 100644 index 0000000000..b22f615034 --- /dev/null +++ b/ext/spl/tests/bug67582.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #67582: Cloned SplObjectStorage with overwritten getHash fails offsetExists() +--FILE-- +attach(new TestObject()); + +foreach($list as $x) var_dump($list->offsetExists($x)); + +$list2 = clone $list; +foreach($list2 as $x) var_dump($list2->offsetExists($x)); + +?> +--EXPECT-- +bool(true) +bool(true)