Mantis - Quercus
Viewing Issue Advanced Details
3764 minor always 11-16-09 12:07 07-20-10 10:47
0003764: fread() on a regular file doesn't return all requested bytes?
I recently encountered an issue where calls to fread() on a regular file returned fewer bytes than requested. This causes issues in code which relies on the PHP core implementation's behavior where fread() and fwrite always write completely for regular files, despite the documentation saying that it may read or write fewer bytes.

I submitted an issue with WordPress [^] about their false assumptions around fread() but I think it would make easier to run existing apps on Quercus if it showed the same behavior as the core PHP app rather than making everyone else fix their PHP code.

Chris Graham   
05-23-10 06:10   
The PHP manual is (at least now) quite specific about when full data won't be returned:
1) EOF (end of file) is reached
2) a packet becomes available (for network streams)
3) 8192 bytes have been read (after opening userspace stream)

None of these are your pedestrian scenarios of fread use, so I believe we have a bug in Quercus and not people's code. I think that's reasonable too, people shouldn't have to worry about issues like this for such a basic function.

I think it is the same as issues 0003894 and 0003765. I examined the Wordpress code referenced here and it was indeed loading large amounts of data, presumably over that 8kb bug-inducing threshold.

The good news is people worried about this bug only need to think of scenarios where they are reading more than 8kb.
07-20-10 10:47   
This Behavior make Wordpress 3.0 in French unusable because Wordpress is unable to load the translation file The fread funtion read only 8164 bytes but the file is much larger.