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

From: Date: Mon, 05 Feb 2018 13:59:53 +0000
Subject: Bug #75917 [Opn]: SplFileObject::seek broken with CSV flags
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213819@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: cmb@php.net Reported by: nyamsprod at gmail dot com Summary: SplFileObject::seek broken with CSV flags Status: Open Type: Bug Package: SPL related Operating System: Irrelevant PHP Version: Next Minor Version Block user comment: N Private report: N New Comment: According to git bisect the relevant commit is <http://git.php.net/?p=php-src.git;a=commit;h=0a45e8f096a04464bda6277c6f3d0b5461737a27> Previous Comments: ------------------------------------------------------------------------ [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 (#213819) next »