#27508 [Asn]: feof() broken for user-defined streams
| From: | adam at trachtenberg dot com | Date: | Tue, 09 Mar 2004 16:31:38 +0000 |
| Subject: | #27508 [Asn]: feof() broken for user-defined streams | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-56174@lists.php.net to get a copy of this message | ||
ID: 27508
User updated by: adam at trachtenberg dot com
Reported By: adam at trachtenberg dot com
Status: Assigned
Bug Type: Network related
Operating System: *
PHP Version: 5CVS-2004-03-05
Assigned To: wez
New Comment:
Here's an example where the class is just a wrapper
around fopen(), fread(), fwrite(), etc.
It's at http://www.trachtenberg.com/patches/
bug27508.php.
In PHP 4, you get:
line1
line2
line3
PHP 5 outputs no data.
Previous Comments:
------------------------------------------------------------------------
[2004-03-09 08:47:27] sniper@php.net
Wez, the fix didn't quite fix it.
Adam, can you please come up with a test case and send it to internals@
? (The one in manual is a bit long, could it be made any shorter?)
------------------------------------------------------------------------
[2004-03-07 20:34:49] adam at trachtenberg dot com
Sorry. Still broken.
------------------------------------------------------------------------
[2004-03-07 16:59:08] wez@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
Most likely fixed now
------------------------------------------------------------------------
[2004-03-05 16:05:11] adam at trachtenberg dot com
Description:
------------
It looks like feof() doesn't work correctly in all cases
for user-defined streams. It seems like the class
stream_eof() method is not being called when feof() is
invoked in PHP.
This works correctly using 4.3.5RC3, but not PHP 5
current CVS. It also works correctly if I do an
fpassthru() on the file pointer and let PHP handle the
feof() check.
Reproduce code:
---------------
See VariableStream class in the manual:
http://us2.php.net/manual/en/function.stream-wrapper-register.php
In particular the while(!feof()) bit.
Expected result:
----------------
line1
line2
line3
string(18) "line1
line2
line3
"
(This is what I get from PHP 4.3.5RC3)
Actual result:
--------------
string(18) "line1
line2
line3
"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27508&edit=1