From:             kraghuba at in dot ibm dot com
Operating system: RHEL 5
PHP version:      5CVS-2007-07-18 (snap)
PHP Bug Type:     Filesystem function related
Bug description:  fgetc() sets end of the file flag when reading on write only 
file

Description:
------------
fgetc() sets the end of the file flag to ture when reading from a file
which opened in write only mode.

This failure is applicable on php5 and php6

php version:
PHP 6.0.0-dev (cli) (built: Jul 18 2007 20:53:03) (GCOV)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2007 Zend Technologies

&
PHP 5.2.4-dev (cli) (built: Jul 18 2007 20:49:53) (GCOV)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

OS : RHEL 5
configure setup:
  ./configure --enable-gcov

Reproduce code:
---------------
<?php
  $fp = fopen("test.txt", "w");
  var_dump( fwrite($fp, "Text") );

  // rewind the file pointer to begining
  var_dump( rewind($fp) );
  var_dump( ftell($fp) );
  var_dump( feof($fp) );

  // try to read
  var_dump( fgetc($fp) );
  var_dump( ftell($fp) );
  var_dump( feof($fp) );

  fclose($fp);
  unlink("test.txt");
?>

Expected result:
----------------
output - php5:
--------------
int(4)
bool(true)
int(0)
bool(false)
bool(false)
int(0)
bool(false)

output - php6:
--------------
int(4)
bool(true)
int(0)
bool(false)
bool(false)
int(0)
bool(false)

Actual result:
--------------
output - php5:
--------------
int(4)
bool(true)
int(0)
bool(false)
bool(false)
int(0)
bool(true)

output - php6:
--------------
int(4)
bool(true)
int(0)
bool(false)
string(1) ""
int(0)
bool(true)

output on php6 when run using run-test.php :
int(4)
bool(true)
int(0)
bool(false)
string(1) "ΓΏ"
int(0)
bool(true)

-- 
Edit bug report at http://bugs.php.net/?id=42036&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=42036&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=42036&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=42036&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42036&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=42036&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42036&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42036&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42036&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42036&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42036&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=42036&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=42036&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42036&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42036&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42036&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42036&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42036&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42036&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42036&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42036&r=mysqlcfg

Reply via email to