Community Forums

"Invalid argument" Problem!

Bug reports here

"Invalid argument" Problem!

Postby Spike » Fri Feb 13, 2009 2:15 pm

Hi,

i worked with lots of shop-systems, but i think your one is really easy to used and also good designed!! Great job, but i have a problem with the "Invalid argument" - Request.

I get this messages on the Front and at the Backend at every Action:


Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18

Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41

Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18

Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41

Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18

Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41

Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18

Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41

Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18

Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41

Warning: Cannot modify header information - headers already sent by (output started at /www/htdocs/user/main/shop/system/library/cache.php:18) in /www/htdocs/user/main/shop/system/library/response.php on line 65


My server use PHP 5.2.6 ....

So, what´s wrong? I set the required folders and cache.php to 777, otherwise it will be crashed, but nothing changed! ;(

Can anyone help me?
Spike
 
Posts: 11
Joined: Fri Feb 13, 2009 8:47 am

Re: "Invalid argument" Problem!

Postby daelsta » Fri Feb 13, 2009 3:24 pm

Hey spike, i had the same problem.
You can put an .htaccess file in your web server's root directory and enter there:

php_value display_errors 0

save it.

This should do the trick.

Greetz daelsta
daelsta
 
Posts: 23
Joined: Thu Oct 11, 2007 4:00 am

Re: "Invalid argument" Problem!

Postby Spike » Fri Feb 13, 2009 3:38 pm

Hey daelsta,

great - that´s it!! Thx!!

Greetz, Spike
Spike
 
Posts: 11
Joined: Fri Feb 13, 2009 8:47 am

Re: "Invalid argument" Problem!

Postby Daniel » Fri Feb 13, 2009 3:48 pm

php_value display_errors 0 is a quick fix but turns off error reporing.

the problem is php's glob function. it won't read files with in the cache directory.

I'm going to fix this properly using fopen.
OpenCart®
Project Owner & Developer.
OpenCart commercial support now available!
User avatar
Daniel
Administrator
 
Posts: 5173
Joined: Fri Nov 03, 2006 10:57 am

Re: "Invalid argument" Problem!

Postby daelsta » Fri Feb 13, 2009 5:20 pm

fixing the error would be the best solution  ;)

ps: daniel, just have to tell you that your new opencart is absolutely awsome. thanks for your work!
daelsta
 
Posts: 23
Joined: Thu Oct 11, 2007 4:00 am

Re: "Invalid argument" Problem!

Postby Daniel » Fri Feb 13, 2009 5:35 pm

Replace your cache file with this:

Code: Select all
<?php
final class Cache {
   private $expire = 3600;

     public function __construct() {
      $files = glob(DIR_CACHE . 'cache.*');
       
      if ($files) {
         foreach ($files as $file) {
               $time = end(explode('.', basename($file)));

               if ($time < time()) {
               unlink($file);
               }
          }
      }
     }

   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);
             }
      }
     }

     public function set($key, $value) {
       $this->delete($key);
      
      $file = DIR_CACHE . 'cache.' . $key . '.' . (time() + $this->expire);
       
      $handle = fopen($file, 'w');

       fwrite($handle, serialize($value));
      
       fclose($handle);
     }
   
     public function delete($key) {
      $files = glob(DIR_CACHE . 'cache.' . $key . '.*');
      
      if ($files) {
          foreach ($files as $file) {
               unlink($file);
          }
      }
     }
}
?>



The problem is that the glob function returns false and not array when nothing is found. Also I would check that you have set the right permission on the cache directory.
Last edited by Daniel on Fri Feb 13, 2009 5:37 pm, edited 1 time in total.
OpenCart®
Project Owner & Developer.
OpenCart commercial support now available!
User avatar
Daniel
Administrator
 
Posts: 5173
Joined: Fri Nov 03, 2006 10:57 am

Re: "Invalid argument" Problem!

Postby daelsta » Fri Feb 13, 2009 5:51 pm

seems like this fixed the error (folder permissions already were 777)

thanks
daelsta
 
Posts: 23
Joined: Thu Oct 11, 2007 4:00 am


Return to Bug Reports

Who is online

Users browsing this forum: No registered users and 15 guests

Hosted by Arvixe Web Hosting