Bug #68948 [Opn]: feof() on temporary streams broken
Edit report at https://bugs.php.net/bug.php?id=68948&edit=1
ID: 68948
Updated by: yunosh@php.net
Reported by: yunosh@php.net
Summary: feof() on temporary streams broken
Status: Open
Type: Bug
Package: Streams related
Operating System: Linux
-PHP Version: master-Git-2015-01-29 (Git)
+PHP Version: 5.6.5
Block user comment: N
Private report: N
New Comment:
Changing version because this is a major regression in the latest stable 5.5 and 5.6 releases too.
Previous Comments:
------------------------------------------------------------------------
[2015-02-07 13:08:53] sjaillet at gmail dot com
It's definitely a bug introduced recently.
Indeed with:
$stream = fopen("php://temp", "r+");
fwrite($stream, "0123456789");
rewind($stream);
var_dump(fread($stream, 1024), ftell($stream), feof($stream));
The output for 5.5.20, 5.6.4, php7@20141201, HHVM 3.5.0 is:
string(10) "0123456789"
int(10)
bool(true)
And now with 5.5.21, 5.6.5, php7@20150101 the output was:
string(10) "0123456789"
int(10)
bool(false)
------------------------------------------------------------------------
[2015-01-29 20:02:47] yunosh@php.net
It still happens if reading 11 bytes. And even with 10 bytes, this would be BC break against PHP 5.
------------------------------------------------------------------------
[2015-01-29 19:15:29] php at mcq8 dot be
This is due to https://github.com/php/php-src/pull/936
You only get an EOF when you tried to read more than there is data.
This is the same behaviour as reading from a file.
------------------------------------------------------------------------
[2015-01-29 17:42:00] yunosh@php.net
Description:
------------
feof() doesn't work properly on temporary streams.
Test script:
---------------
$stream = fopen("php://temp", "r+");
fwrite($stream, "0123456789");
rewind($stream);
var_dump(fread($stream, 10), ftell($stream), feof($stream));
Expected result:
----------------
string(10) "0123456789"
int(10)
bool(true)
Actual result:
--------------
string(10) "0123456789"
int(10)
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68948&edit=1
Thread (10 messages)