[php-src] Issue #8236: \SplFileObject->seek() behaviour has changed (between 8.0.13 - 8.0.16 and 8.1.0-8.1.3)

From: Date: Mon, 21 Mar 2022 17:15:18 +0000
Subject: [php-src] Issue #8236: \SplFileObject->seek() behaviour has changed (between 8.0.13 - 8.0.16 and 8.1.0-8.1.3)
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-240443@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8236 Author: rlmumford ### Description The following code with a 3 line csv file: ```php <?php $file = new \SplFileObject('/local/file/path.csv', 'r'); $file->setFlags(\SplFileObject::READ_CSV); $file->seek(PHP_INT_MAX); $count = $file->key(); print "COUNT OF LINES (seek) : {$count}\n"; $file->rewind(); while ($file->valid()) { $file->fgets(); } print "COUNT OF LINES (while) : {$file->key()}\n"; ``` Resulted in this output on php 8.0.16 and 8.1.3: ``` COUNT OF LINES (seek) : 0 COUNT OF LINES (while) : 4 ``` But I expected this output instead - this is the output I got on all previous version of PHP: ``` COUNT OF LINES (seek) : 4 COUNT OF LINES (while) : 4 ``` Using $file->seek(PHP_INT_MAX) is the most given answer for how to count the number of lines in a CSV in stack overflow, so it is very concerning that this is now broken. ### PHP Version PHP 8.1.3 and PHP 8.0.16 ### Operating System Ubuntu 20.04

« previous php.bugs (#240443) next »