Bug #75917 [NEW]: SplFileObject::seek broken with CSV flags
| From: | nyamsprod at gmail dot com | Date: | Mon, 05 Feb 2018 09:40:40 +0000 |
| Subject: | Bug #75917 [NEW]: SplFileObject::seek broken with CSV flags | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-213813@lists.php.net to get a copy of this message | ||
From: nyamsprod at gmail dot com
Operating system: Irrelevant
PHP version: Next Minor Version
Package: SPL related
Bug Type: Bug
Bug description:SplFileObject::seek broken with CSV flags
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 bug report at https://bugs.php.net/bug.php?id=75917&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75917&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75917&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75917&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75917&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75917&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75917&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75917&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75917&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75917&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75917&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75917&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75917&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75917&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75917&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75917&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75917&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75917&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75917&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75917&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75917&r=mysqlcfg