#46569 [NEW]: SplFileObject: fgetcsv after seek returns wrong line
| From: | duke at masendav dot com | Date: | Thu, 13 Nov 2008 21:57:36 +0000 |
| Subject: | #46569 [NEW]: SplFileObject: fgetcsv after seek returns wrong line | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-130953@lists.php.net to get a copy of this message | ||
From: duke at masendav dot com
Operating system: Macos 10.5
PHP version: 5.2.6
PHP Bug Type: SPL related
Bug description: SplFileObject: fgetcsv after seek returns wrong line
Description:
------------
Using fgetcsv() after seek()-ing to a non-zero position returns the
contents of wrong line - off by one.
Note that seek(0) works as expected. Also, using current() instead of
fgetcsv() gives the correct line.
Source file (5 lines)
first,line
second,line
third,line
fourth,line
fifth,line
Reproduce code:
---------------
<?php
$file = new SplFileObject('lines.csv');
$file->seek(1);
print_r($file->fgetcsv());
Expected result:
----------------
Array
(
[0] => second
[1] => line
)
Actual result:
--------------
Array
(
[0] => third
[1] => line
)
--
Edit bug report at http://bugs.php.net/?id=46569&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46569&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46569&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46569&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=46569&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=46569&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=46569&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=46569&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=46569&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=46569&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=46569&r=support
Expected behavior: http://bugs.php.net/fix.php?id=46569&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=46569&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=46569&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=46569&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46569&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46569&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=46569&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=46569&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=46569&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=46569&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=46569&r=mysqlcfg