Bug #65492 [Com]: Seeking beyond EOF leads to inconsistent results for key() and current()

From: Date: Sun, 29 Jun 2014 07:05:35 +0000
Subject: Bug #65492 [Com]: Seeking beyond EOF leads to inconsistent results for key() and current()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186367@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=65492&edit=1 ID: 65492 Comment by: tim_siebels_aurich at yahoo dot de Reported by: foo at example dot com Summary: Seeking beyond EOF leads to inconsistent results for key() and current() Status: Not a bug Type: Bug Package: SPL related Operating System: any PHP Version: Irrelevant Assigned To: levim Block user comment: N Private report: N New Comment: So, using Iteratormethods after valid() returns false is undefined behaviour? Why do run tests against this? (i.e. SplFileObject_seek_error002.php) This isn't a bug, but "fixing" this would also be fine? Previous Comments: ------------------------------------------------------------------------ [2013-10-16 02:22:00] levim@php.net I should have said "any other Iterator method besides rewind except on iterators that can't be rewound anyway". ------------------------------------------------------------------------ [2013-10-16 01:52:29] levim@php.net When valid() returns false and then you use any other Iterator method the result is undefined. This does properly return false for valid(), so there is no issue here. ------------------------------------------------------------------------ [2013-09-19 18:58:40] bixuehujin at gmail dot com Sorry, the expect result should be: Expect result: ---------------- string(4) "foo " string(4) "bar " ------------------------------------------------------------------------ [2013-09-19 18:55:40] bixuehujin at gmail dot com Another inconsistent: Script: ---------------- $txt = <<< TXT foo bar baz TXT; $file = new SplTempFileObject(-1); $file->fwrite($txt); $file->seek(0); var_dump($file->fgets()); $file->seek(1); var_dump($file->fgets()); Expect result: ---------------- string(4) "foo " string(3) "bar " Actual result: -------------- string(4) "foo " string(3) "baz" BTW: --------------- The issue also existed in SplFileObject. ------------------------------------------------------------------------ [2013-08-21 06:56:34] foo at example dot com Sorry, the last line in the Test Script should read var_dump( $file->key(), $file->current() ); The problem does exist for fgetcsv() though, too. It will return NULL instead of the data at the last line. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=65492 -- Edit this bug report at https://bugs.php.net/bug.php?id=65492&edit=1

« previous php.bugs (#186367) next »