Bug #75917 [Opn->Csd]: SplFileObject::seek broken with CSV flags

From: Date: Mon, 06 Dec 2021 18:05:17 +0000
Subject: Bug #75917 [Opn->Csd]: SplFileObject::seek broken with CSV flags
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-238222@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75917&edit=1 ID: 75917 Updated by: git@php.net Reported by: nyamsprod at gmail dot com Summary: SplFileObject::seek broken with CSV flags -Status: Open +Status: Closed Type: Bug Package: SPL related Operating System: Irrelevant PHP Version: Next Minor Version Block user comment: N Private report: N New Comment: Automatic comment on behalf of Flashwade1990 (author) and cmb69 (committer) Revision: https://github.com/php/php-src/commit/daf79e2d91dc4dd47f516229ebc5922ad35f27ab Log: Fix #75917: SplFileObject::seek broken with CSV flags Previous Comments: ------------------------------------------------------------------------ [2021-12-06 17:42:02] cmb@php.net The following pull request has been associated: Patch Name: Fix #75917: SplFileObject::seek broken with CSV flags. On GitHub: https://github.com/php/php-src/pull/7697 Patch: https://github.com/php/php-src/pull/7697.patch ------------------------------------------------------------------------ [2018-02-05 13:59:52] cmb@php.net According to git bisect the relevant commit is <http://git.php.net/?p=php-src.git;a=commit;h=0a45e8f096a04464bda6277c6f3d0b5461737a27> ------------------------------------------------------------------------ [2018-02-05 09:40:38] nyamsprod at gmail dot com Description: ------------ Prior to PHP7.2.0 SplFileObject::seek would return false if the seeked line did not exists. Since PHP7.2.0 it returns the last line of the file instead. see https://3v4l.org/pl0Kg Test script: --------------- <?php $expected = [ ['john', 'doe', 'john.doe@example.com', '0123456789'], ['jane', 'doe', 'jane.doe@example.com'], ]; $tmp = new SplTempFileObject(); foreach ($expected as $row) { $tmp->fputcsv($row); } $tmp->setFlags(0); $tmp->seek(23); var_dump($tmp->current()); //expected false $tmp->setFlags(SplFileObject::READ_CSV | SplFileObject::SKIP_EMPTY); $tmp->seek(23); var_dump($tmp->current()); //expected false (get the last row instead) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75917&edit=1

« previous php.bugs (#238222) next »