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 (profile)
Status: Closed Package: SPL related
PHP Version: 7.0.23 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gharlan at web dot de
New email:
PHP Version: OS:

 

 [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

Pull Requests

Pull requests:

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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jan 30 23:01:30 2025 UTC