|  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
43 - 21 = ?
Subscribe to this entry?

 [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-2021 The PHP Group
All rights reserved.
Last updated: Fri Sep 17 14:03:37 2021 UTC