php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75173 incorrect behavior of AppendIterator::append in foreach loop
Submitted: 2017-09-08 10:30 UTC Modified: 2017-09-10 18:11 UTC
From: gharlan at web dot de Assigned: jhdxr
Status: Closed Package: SPL related
PHP Version: 7.0.23 OS:
Private report: No CVE-ID:
 [2017-09-08 10:30 UTC] gharlan at web dot de
Description:
------------
https://3v4l.org/itLi1

I guess the change was introduced by https://github.com/php/php-src/pull/2499

Test script:
---------------
<?php

$it = new \AppendIterator();
$it->append(new ArrayIterator(['foo']));

foreach ($it as $item) {
    echo $item;
    
    if ('foo' === $item) {
        $it->append(new ArrayIterator(['bar']));
    }
}

Expected result:
----------------
foobar

Actual result:
--------------
foo

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-09-08 18:14 UTC] jhdxr@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: jhdxr
 [2017-09-10 18:11 UTC] jhdxr@php.net
-Summary: AppendIterator: Changes within foreach ignored +Summary: incorrect behavior of AppendIterator::append in foreach loop -Status: Verified +Status: Assigned -PHP Version: 7.1.9 +PHP Version: 7.0.23
 [2017-09-12 06:08 UTC] krakjoe@php.net
Automatic comment on behalf of jhdxr
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3e11b7fc217ee3ce7a3a2833a062d73537cf6bcc
Log: fix bug #75173 incorrect behavior of AppendIterator::append in foreach loop
 [2017-09-12 06:08 UTC] krakjoe@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Aug 29 15:01:52 2017 UTC