|  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
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:
$a = new stdClass();

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

$rai = new RecursiveArrayIterator($array);

foreach (new RecursiveIteratorIterator($rai) as $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"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-02 21:54 UTC]
Please try using this CVS snapshot:
For Windows (zip):

For Windows (installer):

Works fine on 5.2.6.
 [2008-04-02 22:05 UTC]
I can reproduce using PHP6-CVS.
 [2008-04-02 23:12 UTC]
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]
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
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-2023 The PHP Group
All rights reserved.
Last updated: Wed May 31 03:03:44 2023 UTC