Bug #81551 [NEW]: SplFileObject::fgets( does not advance line pointer after SplFileObject::seek()
From: lucasfbustamante at gmail dot com
Operating system: Unix
PHP version: 8.0.12
Package: Filesystem function related
Bug Type: Bug
Bug description:SplFileObject::fgets( does not advance line pointer after SplFileObject::seek()
Description:
------------
While fixing https://bugs.php.net/bug.php?id=62004, PHP 8.0.1
probably
introduced a bug, where after using SplFileObject::seek($line), the
first subsequent call to SplFileObject::fgets() does not increase the
line pointer.
Test script:
---------------
$file = new \SplTempFileObject();
for ($i = 0; $i < 100; $i++) {
$file->fwrite("Foo\n");
}
$file->seek(50);
var_dump($file->key());
var_dump($file->fgets());
var_dump($file->key());
var_dump($file->fgets());
var_dump($file->key());
// https://3v4l.org/bX3E0
Expected result:
----------------
I expect that using SplFileObject::fgets() will consistently increment
the line pointer by one.
Actual result:
--------------
The first call to SplFileObject::fgets() after calling
SplFileObject::seek($line) will not increment the lint pointer.
Subsequent calls will.
--
Edit bug report at https://bugs.php.net/bug.php?id=81551&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81551&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81551&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81551&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81551&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81551&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81551&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81551&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81551&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81551&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81551&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81551&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81551&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81551&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81551&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81551&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81551&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81551&r=mysqlcfg
Thread (11 messages)
- lucasfbustamante at gmail dot com
- requinix@php.netBug #81551 [Asn->Fbk]: SplFileObject::fgets( does not advance line pointer after SplFileObject::seek()
- lucasfbustamante at gmail dot comBug #81551 [Com]: SplFileObject::fgets( does not advance line pointer after SplFileObject::seek()
- lucasfbustamante at gmail dot comBug #81551 [Com]: SplFileObject::fgets( does not advance line pointer after SplFileObject::seek()
- lucasfbustamante at gmail dot comBug #81551 [Com]: SplFileObject::fgets( does not advance line pointer after SplFileObject::seek()
- requinix@php.netBug #81551 [Fbk]: SplFileObject::fgets( does not advance line pointer after SplFileObject::seek()
- lucasfbustamante at gmail dot comBug #81551 [Com]: SplFileObject::fgets( does not advance line pointer after SplFileObject::seek()
- rene at wp-staging dot comBug #81551 [Com]: SplFileObject::fgets( does not advance line pointer after SplFileObject::seek()
- dharman@php.netBug #81551 [Fbk->Nab]: SplFileObject::fgets( does not advance line pointer after SplFileObject::seek()
- lucasfbustamante at gmail dot comBug #81551 [Com]: SplFileObject::fgets( does not advance line pointer after SplFileObject::seek()
- cmb@php.netBug #81551 [Nab]: SplFileObject::fgets( does not advance line pointer after SplFileObject::seek()