php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42527 Regression with ArrayObject::offsetUnset(): not unsetting (works in 5.2.3)
Submitted: 2007-09-03 09:35 UTC Modified: 2008-03-09 22:13 UTC
From: ahmadj at mediatrac dot net Assigned: helly (profile)
Status: Not a bug Package: SPL related
PHP Version: * OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ahmadj at mediatrac dot net
New email:
PHP Version: OS:

 

 [2007-09-03 09:35 UTC] 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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-03 10:02 UTC] jani@php.net
Did you try the RCs released for PHP 5.2.4?
 [2007-09-03 10:04 UTC] jani@php.net
Assigned to the SPL maintainer.
 [2008-03-09 22:13 UTC] helly@php.net
This is by design. The ctor does not allow by ref per design and this is not going to change.
 [2008-03-09 22:13 UTC] helly@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Sep 19 15:00:02 2025 UTC