PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Caching » Cache_Lite » Bug #9836

fread() in _read function malfunctioning

Details

Request #9836fread() in _read function malfunctioning
Submitted2007-01-15 11:46 UTC
Fromconsensus at gmail dot com
StatusNo Feedback
PackageCache_Lite
PHP Version5.1.2
OSLinux
Roadmaps(Not assigned)

Comments

[2007-01-15 11:46 UTC] consensus at gmail dot com

Description:
------------
Hi,

I've been debugging in for a few hours to hunt my problem down to a buggy @fread() result.

The problem is that the save() call returns false because of the hash value check after storing the file.
The problem is within the "function _read()" of Lite.php

The filesize() function returns the correct size (about 150kb)
But fread($fp,$length); // note that $length is verified to be correct!
returns only 16kb of data (-32 bytes of the previous call..)
I know it's weird, but it's a fact here.

A small testscript which does an fopen,fread,fclose worked fine so it is somehow related to Cache_Lite, or some command cache lite executed within initialization.

I solved the Problem by using a loop while ($fp) {} appending 2kb chunks of data from the local file.
This way the file is loaded correctly.

I suggest to alter this part of Cache_Lite, it should have a very tiny performance impact and will ensure the stability of Cache_Lite in all applications and php versions.

best regards