Jump to content

Resolved - Error Log Message on Accessing Categories as Customer


Dirty Butter

Recommended Posts

Nothing shows up when I turn on debugging, but the error log shows this every time I go to a Category as a customer. It does NOT show up when I open a Category as Admin.

 

 

[07-May-2013 00:03:58] PHP Fatal error:  Call to a member function read() on a non-object in /home/dirtybut/public_html/plushcatalog/classes/seo.class.php on line 740

 

That line of seo.class.php is in bold red below:

private function _getCategoryList($rebuild = false) {
		$language = $GLOBALS['session']->has('language', 'client') ? $GLOBALS['session']->get('language', 'client') : Language::getInstance()->current();
		if ($rebuild || ($this->_cat_dirs = $GLOBALS['cache']->read('seo.category.list.'.$language)) === false) {
			if (($results = $GLOBALS['db']->select('CubeCart_category', array('cat_id', 'cat_name', 'cat_parent_id'), array('hide' => '0'), array('cat_id' => 'DESC'))) !== false) {
				foreach ($results as $result) {
					$this->_cat_dirs[$result['cat_id']] = $result;
				}

Any ideas what "non-object" is being referred to, or how I can find out what the problem is? Or, since it does not show up in debugging - should I just ignore it?

Link to comment
Share on other sites

Call to a member function XX on a non-object (referring to a function - correctly called a method - in a class) is the class that has been instantiated (has been copied to an operational object) that has, for some reason, disappeared from the eyes of PHP. Either the class has been told to destroy itself, as is normal when PHP is preparing to go to sleep after having processed all the code asked of it, or the variable holding the class has become damaged, which is not likely.

 

The error message is pointing to $GLOBALS['cache']->read in line 740 of the script. Perhaps the reason why the Cache class object has disappeared has been discovered, but looking at code for CC521 shows a change:

if ($rebuild || ($this->_cat_dirs = Cache::getInstance()->read('seo.category.list.'.$language)) === false) {

Should the object be gone (again, we may not know why, but at this time, we don't care), just go get the class again.

Link to comment
Share on other sites

OK, I had cache disabled while working on something else and had not turned it back on. So with cache enabled I don't get the error message. Shouldn't there be some way for the code to "know" that cache is not enabled, so it doesn't log this error that is not an error?

Link to comment
Share on other sites

The cache is always instantiated (and a few things are always cached). The admin setting will set the cache to disable -- meaning that what might already be in the cache will not be used, and most new things will not be put in the cache.

 

A disabled cache is not the same as the cache not even being around. It's like a car with four flat tires and a dead battery, as opposed to not having a car at all.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...