Post by inets » Thu Sep 20, 2007 3:51 am

After installation I have this errors

Warning: Invalid argument supplied for foreach() in /home/inets/www/sho2/library/cache/cache.php on line 6

Warning: Invalid argument supplied for foreach() in /home/inets/www/sho2/library/cache/cache.php on line 26

Warning: Invalid argument supplied for foreach() in /home/inets/www/sho2/library/cache/cache.php on line 37

Warning: Invalid argument supplied for foreach() in /home/inets/www/sho2/library/cache/cache.php on line 26

Warning: Invalid argument supplied for foreach() in /home/inets/www/sho2/library/cache/cache.php on line 37

Warning: Invalid argument supplied for foreach() in /home/inets/www/sho2/library/cache/cache.php on line 26

Warning: Invalid argument supplied for foreach() in /home/inets/www/sho2/library/cache/cache.php on line 37

Warning: Invalid argument supplied for foreach() in /home/inets/www/sho2/library/cache/cache.php on line 26

Warning: Invalid argument supplied for foreach() in /home/inets/www/sho2/library/cache/cache.php on line 37

When I push to any link I have this error:
Fatal error: Only variables can be passed by reference in /home/inets/www/sho2/library/cache/cache.php on line 7

Can anybody help me?

Newbie

Posts

Joined
Thu Sep 20, 2007 3:50 am

Post by Daniel » Thu Sep 20, 2007 4:11 am

I think this problem is permissions on the cache directory. Some one else had a problem like this. If not try reinstalling.

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by inets » Thu Sep 20, 2007 5:33 pm

I try reinstall - problem still exists.
On cache dir I have perm. 0777
Cache files in this dir created.

If I edit cache.php file in /library/cache/cache.php

In line 6 put cache path ->  foreach (glob('home/inets/www/sho2/cache/' . 'cache.*') as $file) {

I have this -> Warning: fopen(home/inets/www/sho2/cache/cache.language.1190280267) [function.fopen]: failed to open stream: No such file or directory in /home/inets/www/sho2/library/cache/cache.php on line 18

In cache dir are file with another filename -> cache.language.1190283614
 

Newbie

Posts

Joined
Thu Sep 20, 2007 3:50 am

Post by inets » Thu Sep 20, 2007 5:43 pm

cache.language.1190280267 filed to open
cache.language.1190283614 in cache

----
different file names

Newbie

Posts

Joined
Thu Sep 20, 2007 3:50 am

Post by inets » Thu Sep 20, 2007 6:34 pm

I found where is a problem:
I have PHP5.0.5 and array function end in PHP5.0.5 not work properly  ::)
With this code shop start work.

function __construct() {   
foreach (glob(DIR_CACHE . 'cache.*') as $file) {
# NEW CODE #
                        $var=explode("/",$file);
                        $var=$var[count($var)-1];
$array = explode('.', $var);
                        ##########     
//$array = explode('.', end(explode('/', $file)));  //OLD CODE

      if ($array[2] < time()) {
unlink($file);
      }
    }
  }

Newbie

Posts

Joined
Thu Sep 20, 2007 3:50 am

Post by jakvem » Tue Nov 20, 2007 7:43 pm

All right - but what code needs to be exchanged with what of the code?

New member

Posts

Joined
Wed Oct 17, 2007 5:47 pm

Post by inets » Tue Nov 20, 2007 8:24 pm

I don't remember what file :) I install opencart on another server with PHP 5.X and havn't problems.

Newbie

Posts

Joined
Thu Sep 20, 2007 3:50 am

Post by jakvem » Tue Nov 20, 2007 9:24 pm

Ok. But my server has php5.2.5. so it should be able to read it. Maybe its because you reinstalled that the problem was solved and not because of the server ? Could that be?

New member

Posts

Joined
Wed Oct 17, 2007 5:47 pm

Post by inets » Mon Nov 26, 2007 4:34 am

At first I install on server with PHP 4 and than I have a error.
At second I install opencart on another server with PHP 5 without any problems.

Problem found in array function -> End
http://lv2.php.net/manual/en/function.end.php
That function dont work on PHP4
Maybe need some libraries installed on server?!

Newbie

Posts

Joined
Thu Sep 20, 2007 3:50 am

Post by marthins » Sat Dec 01, 2007 3:34 am

I have the same problem. After install, these are the messages:

Warning: Invalid argument supplied for foreach() in c:\arquivos de programas\easyphp1-8\www\opencart\include\cache.php on line 10

Warning: Cannot modify header information - headers already sent by (output started at c:\arquivos de programas\easyphp1-8\www\opencart\include\cache.php:10) in c:\arquivos de programas\easyphp1-8\www\opencart\include\session.php on line 16

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at c:\arquivos de programas\easyphp1-8\www\opencart\include\cache.php:10) in c:\arquivos de programas\easyphp1-8\www\opencart\include\session.php on line 22

The website and its functions is working but the messages appear on the top of the page. I went to php.net and check that the function end works in php 4 - the version I am running on my server.
Does anybody knows what should I do to fix this issue? thanks

Newbie

Posts

Joined
Sat Dec 01, 2007 3:27 am

Post by marthins » Mon Dec 03, 2007 8:37 pm

Ok, I found the problem...when the function search for cache files and there is no file, the glob() function returns an error.

I just check if there is any files in cache directory before call foreach files in the directory.

thanks

Newbie

Posts

Joined
Sat Dec 01, 2007 3:27 am

Post by franz » Thu Dec 27, 2007 8:09 am

hi folks!
there is a BUG  :o.
Because glob()'ing an empty directory returns false, and so calling foreach (false as $value) will obviously break.

so I recomend you to fix it.
In your_store/library/cache/cache.php

replace function __construct()

Code: Select all

  	function __construct() {

		/**** OLD CODE *****
    	foreach (glob(DIR_CACHE . 'cache.*',GLOB_ONLYDIR) as $file) {
      		$array = explode('.', end(explode('/', $file)));

      		if ($array[2] < time()) {
				unlink($file);
      		}
    	}
		***** END OD OLD CODE *****/
		
		/**** BETTER (NOT BEST) - BUT WORKING NEW CODE ***/
		$files = glob(DIR_CACHE . 'cache.*',GLOB_ONLYDIR) or array();
		if ( is_array ( $files ) ) {
				foreach ($files as $file) {
					$array = explode('.', end(explode('/', $file)));
					if ($array[2] < time()) {
						unlink($file);
					}
				}
		}
		/* ***** END OF NEW CODE ***********************/
  	}

Last edited by franz on Thu Dec 27, 2007 8:31 am, edited 1 time in total.

Newbie

Posts

Joined
Sat Nov 24, 2007 12:55 pm

Post by Dynamyc » Sat May 24, 2008 5:55 am

franz wrote: hi folks!
there is a BUG  :o.
Because glob()'ing an empty directory returns false, and so calling foreach (false as $value) will obviously break.

so I recomend you to fix it.
In your_store/library/cache/cache.php

replace function __construct()

Code: Select all

  	function __construct() {

		/**** OLD CODE *****
    	foreach (glob(DIR_CACHE . 'cache.*',GLOB_ONLYDIR) as $file) {
      		$array = explode('.', end(explode('/', $file)));

      		if ($array[2] < time()) {
				unlink($file);
      		}
    	}
		***** END OD OLD CODE *****/
		
		/**** BETTER (NOT BEST) - BUT WORKING NEW CODE ***/
		$files = glob(DIR_CACHE . 'cache.*',GLOB_ONLYDIR) or array();
		if ( is_array ( $files ) ) {
				foreach ($files as $file) {
					$array = explode('.', end(explode('/', $file)));
					if ($array[2] < time()) {
						unlink($file);
					}
				}
		}
		/* ***** END OF NEW CODE ***********************/
  	}

i've modified this and the same problem bother me,the host PHP version is : 5.8.8

Newbie

Posts

Joined
Fri May 23, 2008 5:05 am

Post by dienast » Sat Jun 07, 2008 5:38 pm

If you have tried every option possible than you can always adjust your htaccess file by renaming it as .htaccess and adding this line in it:

php_flag display_errors off

Only use this option if the whole webshop works correctly but you only get those anoying warnings.

Newbie

Posts

Joined
Fri Apr 25, 2008 12:58 am
Who is online

Users browsing this forum: No registered users and 2 guests