Post by Spike » Fri Feb 13, 2009 10: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?

Newbie

Posts

Joined
Fri Feb 13, 2009 4:47 pm

Post by daelsta » Fri Feb 13, 2009 11: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

New member

Posts

Joined
Thu Oct 11, 2007 12:00 pm

Post by Spike » Fri Feb 13, 2009 11:38 pm

Hey daelsta,

great - that´s it!! Thx!!

Greetz, Spike

Newbie

Posts

Joined
Fri Feb 13, 2009 4:47 pm

Post by Daniel » Fri Feb 13, 2009 11: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.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by daelsta » Sat Feb 14, 2009 1:20 am

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!

New member

Posts

Joined
Thu Oct 11, 2007 12:00 pm

Post by Daniel » Sat Feb 14, 2009 1:35 am

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 Sat Feb 14, 2009 1:37 am, edited 1 time in total.

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by daelsta » Sat Feb 14, 2009 1:51 am

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

thanks

New member

Posts

Joined
Thu Oct 11, 2007 12:00 pm
Who is online

Users browsing this forum: No registered users and 15 guests