mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-8.1'
* PHP-8.1: Fix #75917: SplFileObject::seek broken with CSV flags
This commit is contained in:
commit
fd2a6d2360
2 changed files with 26 additions and 0 deletions
|
@ -1936,6 +1936,8 @@ static int spl_filesystem_file_read_line_ex(zval * this_ptr, spl_filesystem_obje
|
|||
|
||||
/* 1) use fgetcsv? 2) overloaded call the function, 3) do it directly */
|
||||
if (SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_READ_CSV) || intern->u.file.func_getCurr->common.scope != spl_ce_SplFileObject) {
|
||||
spl_filesystem_file_free_line(intern);
|
||||
|
||||
if (php_stream_eof(intern->u.file.stream)) {
|
||||
if (!silent) {
|
||||
zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Cannot read from file %s", ZSTR_VAL(intern->file_name));
|
||||
|
|
24
ext/spl/tests/bug75917.phpt
Normal file
24
ext/spl/tests/bug75917.phpt
Normal file
|
@ -0,0 +1,24 @@
|
|||
--TEST--
|
||||
Bug #75917 (SplFileObject::seek broken with CSV flags)
|
||||
--FILE--
|
||||
<?php
|
||||
$expected = [
|
||||
['john', 'doe', 'john.doe@example.com', '0123456789'],
|
||||
['jane', 'doe', 'jane.doe@example.com'],
|
||||
];
|
||||
|
||||
$tmp = new SplTempFileObject();
|
||||
foreach ($expected as $row) {
|
||||
$tmp->fputcsv($row);
|
||||
}
|
||||
$tmp->setFlags(0);
|
||||
$tmp->seek(23);
|
||||
var_dump($tmp->current());
|
||||
|
||||
$tmp->setFlags(SplFileObject::READ_CSV | SplFileObject::SKIP_EMPTY);
|
||||
$tmp->seek(23);
|
||||
var_dump($tmp->current());
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
bool(false)
|
Loading…
Add table
Add a link
Reference in a new issue