php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44615 RecursiveArrayIterator doesnt handle correctly objects stored in it
Submitted: 2008-04-02 15:36 UTC Modified: 2008-05-06 23:15 UTC
From: doctorrock83 at gmail dot com Assigned: colder (profile)
Status: Closed Package: SPL related
PHP Version: 6-CVS OS: Windows XP
Private report: No CVE-ID: None
 [2008-04-02 15:36 UTC] doctorrock83 at gmail dot com
Description:
------------
RecursiveArrayIterator doesn't seem to handle objects stored in it correctly.

If you store anything else into the RecursiveArrayIterator (ie : strings, integers, or even ressources ), they are served back from the iterator.
But if you store an object of any class into it, then it disappears while iterating.

PS : Perhaps a RecursiveIteratorIterator bug, dunnow :-)

Reproduce code:
---------------
<?php
$a = new stdClass();

$array = array(array('z',$a),array('q','s'));

$rai = new RecursiveArrayIterator($array);

foreach (new RecursiveIteratorIterator($rai) as $t) {
    var_dump($t);
}

Expected result:
----------------
string(1) "z"
object(stdClass)#1 (0) {
}
string(1) "q"
string(1) "s"


Actual result:
--------------
string(1) "z"
string(1) "q"
string(1) "s"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-02 21:54 UTC] felipe@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows (zip):
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

For Windows (installer):

  http://snaps.php.net/win32/php5.2-win32-installer-latest.msi

Works fine on 5.2.6.
 [2008-04-02 22:05 UTC] felipe@php.net
I can reproduce using PHP6-CVS.
 [2008-04-02 23:12 UTC] felipe@php.net
Sorry, it works fine on 5.3, fails on 5.2.6 and HEAD.

This is probably related to bug #38618, and looks that wasn't defined the fix/behavior, right Marcus? Hence, it wasn't merged into branches.

Assigned to maintainer.
 [2008-05-06 23:15 UTC] colder@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

This feature is now controlled by the flag RecursiveArrayIterator::CHILD_ARRAYS_ONLY which is no longer enabled by default.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 22:01:28 2024 UTC