Bug #81477 [Ver->Csd]: Fix #81477: LimitIterator + SplFileObject regression in 8.0.1
Edit report at https://bugs.php.net/bug.php?id=81477&edit=1
ID: 81477
Updated by: git@php.net
Reported by: john at zerocrates dot org
Summary: Fix #81477: LimitIterator + SplFileObject regression
in 8.0.1
-Status: Verified
+Status: Closed
Type: Bug
Package: SPL related
Operating System: Linux
PHP Version: 8.0.11
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of cmb69
Revision: https://github.com/php/php-src/commit/ee5711de33fd673bcb8672c09c63ea349a306f5a
Log: Fix #81477: LimitIterator + SplFileObject regression in 8.0.1
Previous Comments:
------------------------------------------------------------------------
[2021-09-27 11:09:17] cmb@php.net
The following pull request has been associated:
Patch Name: Fix #81477: LimitIterator + SplFileObject regression in 8.0.1
On GitHub: https://github.com/php/php-src/pull/7518
Patch: https://github.com/php/php-src/pull/7518.patch
------------------------------------------------------------------------
[2021-09-25 00:49:49] john at zerocrates dot org
Description:
------------
PHP 8.0.1+ seems to introduce a new issue with LimitIterator and SplFileObject, where the wrapping
LimitIterator just is "empty" immediately.
I encountered this with READ_CSV | READ_AHEAD | SKIP_EMPTY as the SplFileObject flags but it seems
to just be READ_AHEAD that causes the issue. I also initially thought this only happened when the
offset was 1 line away from EOF but I can reproduce further away.
Just a guess that it may be related to or a regression caused by Bug 68004 given the 8.0.1
coincidence.
Test script:
---------------
See https://3v4l.org/2SRvp
<?php
$s = fopen('/tmp/test.csv', 'w+');
fwrite($s, "foo,bar\nbaz,bat\nmore,data\n");
fclose($s);
$sfo = new SplFileObject('/tmp/test.csv');
$sfo->setFlags(SplFileObject::READ_AHEAD);
$limitIter = new LimitIterator($sfo, 1, -1);
foreach($limitIter as $row) {
var_dump($row);
}
Expected result:
----------------
string(8) "baz,bat
"
string(10) "more,data
"
string(0) ""
Actual result:
--------------
[no output]
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81477&edit=1
Thread (4 messages)