From:             david at grudl dot com
Operating system: 
PHP version:      5.4.6
Package:          SPL related
Bug Type:         Bug
Bug description:AppendIterator sometimes iterates 2 times over first iterator

Description:
------------
Due to this bug I cannot use PHP AppendIterator because it gives wrong
(doubled) results. It is very hard to explain it, so there is isolated use
case http://davidgrudl.com/tmp/appenditerator.zip

It affects all PHP versions.

Test script:
---------------
/*
Directory structure:

        /one
                a
                /b
                        c
                        d

        /two
*/


class Filter extends FilterIterator
{
        public function accept()
        {
                $this->x++;
                return $this->x > 1;
        }
}


$append = new AppendIterator();
$iterator = new RecursiveDirectoryIterator('one',
RecursiveDirectoryIterator::SKIP_DOTS);
$iterator = new RecursiveIteratorIterator($iterator);
$iterator = new Filter($iterator);
$append->append($iterator);

$iterator = new RecursiveDirectoryIterator('two');
$iterator = new RecursiveIteratorIterator($iterator);
$append->append($iterator);

foreach($append as $file){
    echo $file, "\n";
}


Expected result:
----------------
Should print:
  one/b/c
  one/b/d


Actual result:
--------------
Prints:
  one/b/c
  one/b/d
  one/b/c
  one/b/d


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

Reply via email to