php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74519 strange behavior of AppendIterator
Submitted: 2017-05-01 10:31 UTC Modified: -
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: jhdxr@php.net Assigned:
Status: Closed Package: SPL related
PHP Version: 7.0.18 OS: irrelevant
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: jhdxr@php.net
New email:
PHP Version: OS:

 

 [2017-05-01 10:31 UTC] jhdxr@php.net
Description:
------------
If an ArrayIterator was appended to an AppendIterator, and the inner pointer of ArrayIterator was changed (foreach, ->next or something else), it would also effect AppendIterator in a strange way, see the test script (https://3v4l.org/EavLv) below. 

I'm not sure if the iterators were appended by reference or value (clone a new copy), but current result cannot be explained in either way. 

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

$iterator = new \AppendIterator();
$events = new \ArrayIterator([1,2,3,4,5]);
$iterator->append($events);

$events->next();

while($iterator->valid()) {
	echo $iterator->current(), "\n";
	$iterator->next();
}

Expected result:
----------------
append reference:
2
3
4
5

or
append clone:
1
2
3
4
5

Actual result:
--------------
1
3
4
5

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-08 09:19 UTC] krakjoe@php.net
Automatic comment on behalf of jhdxr
Revision: http://git.php.net/?p=php-src.git;a=commit;h=01eafceea12913e710b992fd88e5ab1e23662447
Log: Fixed bug #74519 strange behavior of AppendIterator
 [2018-02-08 09:19 UTC] krakjoe@php.net
-Status: Open +Status: Closed
 [2018-02-08 09:19 UTC] krakjoe@php.net
Automatic comment on behalf of jhdxr
Revision: http://git.php.net/?p=php-src.git;a=commit;h=495508ecebb042bf252510fc508ac3745b588bb9
Log: fix #74519 strange behavior of AppendIterator
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Oct 07 11:01:28 2024 UTC