|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75917 SplFileObject::seek broken with CSV flags
Submitted: 2018-02-05 09:40 UTC Modified: 2018-02-05 13:59 UTC
From: nyamsprod at gmail dot com Assigned:
Status: Open Package: SPL related
PHP Version: Next Minor Version OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: nyamsprod at gmail dot com
New email:
PHP Version: OS:


 [2018-02-05 09:40 UTC] nyamsprod at gmail dot com
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.


Test script:

$expected = [
    ['john', 'doe', '', '0123456789'],
    ['jane', 'doe', ''],

$tmp = new SplTempFileObject();
foreach ($expected as $row) {
var_dump($tmp->current()); //expected false
$tmp->setFlags(SplFileObject::READ_CSV | SplFileObject::SKIP_EMPTY);
var_dump($tmp->current());  //expected false (get the last row instead)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-05 13:59 UTC]
According to `git bisect` the relevant commit is
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Oct 01 05:01:24 2020 UTC