php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81477 Fix #81477: LimitIterator + SplFileObject regression in 8.0.1
Submitted: 2021-09-25 00:49 UTC Modified: 2021-09-27 11:08 UTC
From: john at zerocrates dot org Assigned:
Status: Closed Package: SPL related
PHP Version: 8.0.11 OS: Linux
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: john at zerocrates dot org
New email:
PHP Version: OS:

 

 [2021-09-25 00:49 UTC] 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]

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-09-27 11:08 UTC] cmb@php.net
-Summary: LimitIterator + SplFileObject regression/changed behavior in 8.0.1+ +Summary: Fix #81477: LimitIterator + SplFileObject regression in 8.0.1 -Status: Open +Status: Verified
 [2021-09-27 11:09 UTC] 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-29 14:19 UTC] git@php.net
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
 [2021-09-29 14:19 UTC] git@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 10:01:26 2024 UTC