[php-src] Issue #8270: SplFileObject method seek doesn't work as expected
| From: | ASiRoS | Date: | Tue, 29 Mar 2022 12:48:43 +0000 |
| Subject: | [php-src] Issue #8270: SplFileObject method seek doesn't work as expected | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-240556@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8270
Author: ASiRoS
### Description
The following code:
```php
<?php
$splFileObject = new SplFileObject('any.csv');
$splFileObject->setFlags(
SplFileObject::READ_CSV
| SplFileObject::READ_AHEAD
| SplFileObject::SKIP_EMPTY
| SplFileObject::DROP_NEW_LINE
);
$splFileObject->seek(0);
$splFileObject->key(); // 0 Returns as expected
$splFileObject->seek(1);
$splFileObject->key(); // 1 Returns as expected
$splFileObject->seek(2);
$splFileObject->key(); // 1 But if we give anything more than 1, it will return 1
```
Resulted in this output:
```
Seek doesn't get you to the expected line, but instead gets you to the second one (1).
```
But I expected this output instead:
```
Seek will move to the expected lines that exists.
```
seek works fine for PHP 7.4 and PHP 8.1, but results in this error for PHP 8.0
### PHP Version
PHP 8.0.16
### Operating System
Ubuntu 20.04