From:             [email protected]
Operating system: Mac OS X 10.5.6 PPC
PHP version:      5.2.8
PHP Bug Type:     SPL related
Bug description:  iterator_to_array() does not return every inner iterator of 
an AppendIterator

Description:
------------
The SPL iterator_to_array() function does not appear to include every 
inner iterator contained within an AppendIterator. It seems that it only 
processes the very last iterator that was appended.

I'd expect that array conversion would parallel the traversal of 
foreach, but it does not. To maintain consistency within SPL itself, I'd 
suggest that this be corrected.

If the behavior can be confirmed, I'm willing to supply the patch & 
regression tests. I'd like more karma.

I've also verified this w/ version 5.2.6 on the same platform and 
version 5.2.3-1ubuntu6 on x86 32-bit Linux.

Reproduce code:
---------------
<?php
$r = new AppendIterator();
$r->append(new ArrayIterator(array(1,2)));
$r->append(new ArrayIterator(array(3,4)));
$r->append(new ArrayIterator(array(5,6)));

// only sees 5 and 6:
print_r(iterator_to_array($r));

// this works as expected: foreach ($r as $i) echo $i;
?>



Expected result:
----------------
Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
    [4] => 5
    [5] => 6
)






Actual result:
--------------
Array
(
    [0] => 5
    [1] => 6
)






-- 
Edit bug report at http://bugs.php.net/?id=46958&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=46958&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=46958&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=46958&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=46958&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=46958&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=46958&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=46958&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=46958&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=46958&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=46958&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=46958&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=46958&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=46958&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=46958&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=46958&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=46958&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=46958&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=46958&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=46958&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=46958&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=46958&r=mysqlcfg

Reply via email to