Post by prahastu » Mon Oct 18, 2010 9:05 pm

Hello,,

I have a new problem in my online store using open cart 1.4.8b.
It has been uploaded some days ago and I find no problem since I found this message above the header:
Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home/xxxx/public_html/system/library/cache.php on line 27Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home/xxxx/public_html/system/library/cache.php on line 27Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home/xxxx/public_html/system/library/cache.php on line 27Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home/gudangd/public_html/system/library/cache.php on line 27Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home/xxxx/public_html/system/library/cache.php on line 27
* The xxx is the user of hosting

I don't know why it can be shown.
But that's very annoying.
I was trying to refresh, close my browser and open it again. But it has no result.

Can someone help me?

Thank's

Newbie

Posts

Joined
Thu Oct 07, 2010 4:11 am

Post by JAY6390 » Mon Oct 18, 2010 9:29 pm

Open

Code: Select all

/system/library/cache.php
Find

Code: Select all

    public function get($key) {
        $files = glob(DIR_CACHE . 'cache.' . $key . '.*');
        
        if ($files) {
            foreach ($files as $file) {
                  $handle = fopen($file, 'r');
                  $cache = fread($handle, filesize($file));
      
                  fclose($handle);

                  return unserialize($cache);
                }
        }
      } 
and replace with

Code: Select all

    public function get($key) {
        $files = glob(DIR_CACHE . 'cache.' . $key . '.*');
        
        if ($files) {
            foreach ($files as $file) {
                  $cache = file_get_contents($file);
                  return unserialize($cache);
                }
        }
      } 
This should really be how it's written in the first place to be honest

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by susanjoy » Mon Dec 27, 2010 11:58 am

Thank you! Worked perfectly!

Newbie

Posts

Joined
Mon Nov 29, 2010 11:44 am

Post by JAY6390 » Sun Jan 16, 2011 12:23 am

No problem :)

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by Qphoria » Sun Jan 16, 2011 2:48 am

JAY6390 wrote: This should really be how it's written in the first place to be honest
I agree.. In fact the php manual states it right on the page:
http://php.net/manual/en/function.file-get-contents.php
file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 7 guests