#43729 [NEW]: Fread isnt able to read
From: rc at opelgt dot org
Operating system: Mac OS 10.4.11
PHP version: 4.4.7
PHP Bug Type: Filesystem function related
Bug description: Fread isnt able to read
Description:
------------
Although the pointer is at position 0 and filesize is cached with the
value of 4 fread reads nothing.
A clearstatcache is necessary for fread to operate correct.
Reproduce code:
---------------
<?php
$str1 = '1234';
$str2 = '56';
$datei = 'test.txt';
$dh = fopen ($datei,"w");
fwrite($dh, $str1);
fclose($dh);
$dh = fopen ($datei,"r+");
echo 'content: '.fread($dh, filesize($datei))."<BR>\n";
echo 'pointer after write at: '.ftell($dh).'<br>';
ftruncate($dh, '0');
echo 'pointer after truncate at: '.ftell($dh).'<br>';
echo 'filesize after truncate is: '.filesize($datei).'<br>';
fwrite($dh, $str2);
echo 'pointer after second write at: '.ftell($dh).'<br>';
rewind($dh);
echo 'pointer after rewind at: '.ftell($dh).'<br>';
echo 'content: '.fread($dh, filesize($datei)).'<br>';
clearstatcache();
echo 'content: '.fread($dh, filesize($datei));
fclose($dh);
?>
Expected result:
----------------
content: 1234
pointer after write at: 4
pointer after truncate at: 4
filesize after truncate is: 4
pointer after second write at: 6
pointer after rewind at: 0
content: 56
content: 56
Actual result:
--------------
content: 1234
pointer after write at: 4
pointer after truncate at: 4
filesize after truncate is: 4
pointer after second write at: 6
pointer after rewind at: 0
content:
content: 56
--
Edit bug report at http://bugs.php.net/?id=43729&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43729&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43729&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43729&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43729&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=43729&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=43729&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=43729&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=43729&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=43729&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=43729&r=support
Expected behavior: http://bugs.php.net/fix.php?id=43729&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=43729&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=43729&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=43729&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43729&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=43729&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=43729&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=43729&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=43729&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=43729&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=43729&r=mysqlcfg
Thread (2 messages)
- rc at opelgt dot org