Bug #81477 [PATCH]: Fix #81477: LimitIterator + SplFileObject regression in 8.0.1

From: Date: Mon, 27 Sep 2021 11:09:17 +0000
Subject: Bug #81477 [PATCH]: Fix #81477: LimitIterator + SplFileObject regression in 8.0.1
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236856@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 Patch added by: cmb@php.net Reported by: john at zerocrates dot org Summary: Fix #81477: LimitIterator + SplFileObject regression in 8.0.1 Status: Verified Type: Bug Package: SPL related Operating System: Linux PHP Version: 8.0.11 Block user comment: N Private report: N New Comment: 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 Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#236856) next »