#33825 [Opn->Bgs]: stream_eof() is opposite behavior from 5.0.4

From: Date: Fri, 22 Jul 2005 17:59:49 +0000
Subject: #33825 [Opn->Bgs]: stream_eof() is opposite behavior from 5.0.4
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-82338@lists.php.net to get a copy of this message
ID: 33825 Updated by: wez@php.net Reported By: cellog@php.net -Status: Open +Status: Bogus Bug Type: Filesystem function related Operating System: windows XP PHP Version: 5.1.0b3 New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2005-07-22 19:42:40] 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 18:51:46] 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) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33825&edit=1

« previous php.bugs (#82338) next »