#42527 [Asn]: Regression with ArrayObject::offsetUnset(): not unsetting (works in 5.2.3)

From: Date: Sun, 09 Mar 2008 22:13:31 +0000
Subject: #42527 [Asn]: Regression with ArrayObject::offsetUnset(): not unsetting (works in 5.2.3)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-123109@lists.php.net to get a copy of this message
ID: 42527 Updated by: helly@php.net Reported By: ahmadj at mediatrac dot net Status: Assigned Bug Type: SPL related -Operating System: CentOS 5 +Operating System: * -PHP Version: 5.2.4 +PHP Version: * Assigned To: helly New Comment: This is by design. The ctor does not allow by ref per design and this is not going to change. Previous Comments: ------------------------------------------------------------------------ [2007-09-03 10:04:14] jani@php.net Assigned to the SPL maintainer. ------------------------------------------------------------------------ [2007-09-03 10:02:05] jani@php.net Did you try the RCs released for PHP 5.2.4? ------------------------------------------------------------------------ [2007-09-03 09:35:27] ahmadj at mediatrac dot net Description: ------------ At PHP 5.23 ArrayObject::offsetUnset() works as I expected, but at PHP 5.24 it doesn't work as I expected. The array offset doesn't destroy/unset properly and it still reside in the array. Reproduce code: --------------- $ArrayField = array("clip.clip_id", "clip.clip_title", "clip.clip_published_date", "media.media_name", "conditional_category.conditional_id", "conditional_category.conditional_name", "client_category_set.client_cids", "client_category_set.category_name"); $ArrayGroups = array("clip.clip_published_date", "client_category_set.category_name", "clip.clip_title", "clip.clip_id"); $collection = new ArrayObject($ArrayField); for ($iter = $collection->getIterator(); $iter->valid(); $iter->next()) { if (!in_array($iter->current(), $ArrayGroups)) { $collection->offsetUnset($iter->key()); } } Expected result: ---------------- At PHP 5.22 & 5.23, the $arrayField at offset(3,4,5,6) get unset properly, but when I try this code at PHP 5.24 the $arrayField at those offsets didn't get unset as PHP 5.22/5.23 did. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42527&edit=1

« previous php.bugs (#123109) next »