ID: 32810
Updated by: [EMAIL PROTECTED]
Reported By: matteo at beccati dot com
-Status: Open
+Status: Assigned
Bug Type: Filesystem function related
-Operating System: Any
+Operating System: *
-PHP Version: 4.3.10
+PHP Version: 4.*, 5.*
-Assigned To:
+Assigned To: wez
New Comment:
Wez breaks, Wez fixes. (Streams stuff broke this)
Previous Comments:
------------------------------------------------------------------------
[2005-04-24 16:04:54] matteo at beccati dot com
Description:
------------
In recent PHP versions, fread only reads 8192 bytes from a file
generated with tmpfile().
I've already seen bug reports #29023 and #30936 which seem strongly
related to this issue. From what I can see, fread on local files isn't
limited to the PHP chunk size of 8192, while a fread on a tmpfile acts
like it was i.e. a network stream, breaking backwards compatibility. I
found out this issue investigating a recently reported bug for
phpAdsNew, which uses this function to deal with remote ftp-stored
files.
IMVHO this can be considered a bug in in the tmpfile() implementation.
If you don't agree, well... I suggest to mark it as a documentation
bug, because I couldn't find nothing related to the 8192 bytes limit in
the manual.
Versions/OS tested and affected:
PHP 4.3.10 Linux
PHP 4.3.11 FreeBSD and Windows
PHP 5.0.4 Windows
Versions/OS tested and unaffected:
PHP 4.3.4 Windows
Reproduce code:
---------------
<?php
$fp = tmpfile();
// This would give the correct result
// $fp = fopen('/tmp/test.dat', 'w+');
fwrite($fp, str_repeat('0', 100000));
$size = ftell($fp);
rewind($fp);
$buf = fread($fp, $size);
echo "Bytes written: ".$size."\n";
echo "Bytes read: ".strlen($buf)."\n";
fclose($fp);
?>
Expected result:
----------------
Bytes written: 100000
Bytes read: 100000
Actual result:
--------------
Bytes written: 100000
Bytes read: 8192
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32810&edit=1