Bug #81477 [Ver->Csd]: Fix #81477: LimitIterator + SplFileObject regression in 8.0.1

From: Date: Wed, 29 Sep 2021 14:19:46 +0000
Subject: Bug #81477 [Ver->Csd]: Fix #81477: LimitIterator + SplFileObject regression in 8.0.1
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236921@lists.php.net to get a copy of this message
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)

« previous php.bugs (#236921) next »