From: shashank dot araokar at gmail dot com Operating system: Windows XP PHP version: 5.2.4 PHP Bug Type: Reproducible crash Bug description: filesize does not work ever
Description: ------------ The filesize() function always fails, even if the file opens up properly and without warnings (it has been verified that there is no file access issue and also that PHP knows that the file is there). The warning is Warning filesize: stat failed for resource #xxx etc. Please note that it has been confirmed at absolutely all permissions have been granted to both the directory and the file and that the file is existing and can also be opened by PHP. Either this is a serious error or a function as ordinary as filesize() is made too complex to use, which in itself is a problem! This has been tested on several servers. If the file does not exist, a proper warning is thrown, meaning that non-existence of the file is not any issue. Reproduce code: --------------- <?php $file=fopen("uploads/test.txt","rb"); $contents=fread($file, filesize($file)); fclose($file); ?> Expected result: ---------------- (no output, no warnings, no errors!) Actual result: -------------- Warning: filesize() [function.filesize]: stat failed for Resource id #3 in /www/110mb.com/w/a/v/i/c/l/e/_/wavicle/htdocs/test.php on line 4 Warning: fread() [function.fread]: Length parameter must be greater than 0 in /www/110mb.com/w/a/v/i/c/l/e/_/wavicle/htdocs/test.php on line 4 -- Edit bug report at http://bugs.php.net/?id=43166&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43166&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43166&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43166&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43166&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43166&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43166&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43166&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43166&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43166&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43166&r=support Expected behavior: http://bugs.php.net/fix.php?id=43166&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43166&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43166&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43166&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43166&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43166&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43166&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43166&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43166&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43166&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43166&r=mysqlcfg