Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.8.3

Bug #4236 fread PHP warning on zero length read
Submitted: 2005-04-27 17:59 UTC
From: rick dot overman at gmail dot com Assigned: fab
Status: Closed Package: Cache_Lite
PHP Version: 4.3.10 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2005-04-27 17:59 UTC] rick dot overman at gmail dot com
Description: ------------ In Lite.php line 638 $data = @fread($fp, $length); Comment from http://www.php.net/fread ------------------------------------- Somewhere between 4.2.3 and 4.3.9, the behaviour of fread() was changed slightly. When you ask to fread() 0 bytes of data, it spits out a warning (IMO for no good reason. I think reading 0 bytes is perfectly valid, if not very useful.) Consequently, to write warning-free code using fread, you'd have to take code like this: $content=fread($fd,filesize($myfile)); and replace it with this: $content=''; $length=filesize($myfile); if($length) { $content = fread($fd, $length); } ...or this, depending on your taste: $length=filesize($myfile); if($length) { $content = fread($fd, $length); } else { $content=''; } Reproduce code: --------------- Read an empty cache. Expected result: ---------------- No PHP warning if cache empty. Actual result: -------------- Produces a PHP Warning.

Comments

 [2005-05-14 09:37 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!