From: [EMAIL PROTECTED] Operating system: n/a PHP version: 5CVS-2006-04-21 (CVS) PHP Bug Type: Streams related Bug description: if userspace stream is present, fread() reads in 8192 max, otherwise it works
Description: ------------ fread($fp, 20000); will read in 20000 bytes from a local file, but is a userspace stream is defined anywhere, it will only read in 8192 bytes, without any warning or error. This is actually similar to Bug #30936, but as I say the problem here is that the presence of a userspace stream handler changes the behavior of fread() - any indeterminate behavior is bad. I wonder if the fix from #32810 could be helpful for this problem as well? Reproduce code: --------------- <?php // paste in the stream code from the example in the manual // be sure to include stream_wrapper_register error_reporting(E_ALL | E_STRICT); $file = dirname(__FILE__) . '/footest.txt'; $x = str_repeat('1', 8192); $fp = fopen($file, 'w'); for ($i = 0; $i < 5; $i++) { fwrite($fp, $x); } fclose($fp); $fp = fopen($file, 'r'); $outsidecontents = fread($fp, 20000); fclose($fp); var_dump('size of contents 1 = ' . strlen($outsidecontents)); $outsidecontents = file_get_contents($file); var_dump('size of contents 2 = ' . strlen($outsidecontents)); ?> Expected result: ---------------- string(26) "size of contents 1 = 20000" string(26) "size of contents 2 = 40960" Actual result: -------------- string(25) "size of contents 1 = 8192" string(26) "size of contents 2 = 40960" -- Edit bug report at http://bugs.php.net/?id=37158&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37158&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=37158&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37158&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=37158&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=37158&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=37158&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=37158&r=needscript Try newer version: http://bugs.php.net/fix.php?id=37158&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=37158&r=support Expected behavior: http://bugs.php.net/fix.php?id=37158&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=37158&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=37158&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=37158&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37158&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=37158&r=dst IIS Stability: http://bugs.php.net/fix.php?id=37158&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=37158&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=37158&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=37158&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=37158&r=mysqlcfg