php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33825 stream_eof() is opposite behavior from 5.0.4
Submitted: 2005-07-22 18:51 UTC Modified: 2005-07-22 19:59 UTC
From: cellog@php.net Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.1.0b3 OS: windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: cellog@php.net
New email:
PHP Version: OS:

 

 [2005-07-22 18:51 UTC] cellog@php.net
Description:
------------
in 5.0.4, if stream_eof() returns false, feof() returns true, in 5.1.0b3, if stream_eof() returns true, feof() returns true.

In addition to the small test below, a slightly larger real-world streams test is available in cvs at pear/PHP_Archive/tests/eof.phpt

Reproduce code:
---------------
<?php
class Mystream
{
    static $a = false;
    function stream_open()
    {
        return true;
    }

    function stream_eof()
    {
        var_dump(self::$a);
        return self::$a;
    }

    function stream_seek()
    {
        return true;
    }

    function stream_tell()
    {
        return 0;
    }
}
stream_wrapper_register('testing', 'Mystream');
$fp = fopen('testing://blah', 'r');
var_dump(1, feof($fp));
fseek($fp, 100);
Mystream::$a = true;
var_dump(2, feof($fp));
?>

Expected result:
----------------
bool(false)
int(1)
bool(true)
bool(true)
int(2)
bool(false)

Actual result:
--------------
bool(false)
int(1)
bool(false)
bool(true)
int(2)
bool(true)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-22 19:42 UTC] cellog@php.net
since there has been some question of the brilliance of the test script on irc, I will provide one that appeals to the objectors

<?php
class Mystream
{
    private $snobs = 0;
    function stream_open()
    {
        return true;
    }

    function stream_eof()
    {
        var_dump($this->snobs);
        return !($this->snobs >= 99);
    }

    function stream_seek($a)
    {
        $this->snobs = $a;
        return true;
    }

    function stream_tell()
    {
        return $this->snobs;
    }
}
stream_wrapper_register('testing', 'Mystream');
$fp = fopen('testing://blah', 'r');
var_dump(1, feof($fp));
fseek($fp, 100);
Mystream::$a = true;
var_dump(2, feof($fp));
?>
 [2005-07-22 19:59 UTC] wez@php.net
See Bug #27508; 5.0 actually was broken and flipped the meaning of the return value (blame hartmut for that one, I think :)

Aside from that, your sample script still doesn't work properly or make much sense.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 12:01:33 2025 UTC