Dirty Butter Posted July 10, 2012 Share Posted July 10, 2012 PHP Fatal error: Call to a member function select() on a non-object in /home/dirtybut/public_html/plushcatalog/classes/seo.class.php on line 225 Working through errors I've discovered in my error log. I've checked my urls and they look right, and my Google Feed seems OK, too. Any ideas? Here's line 225 in seo.class.php if (($item = $GLOBALS['db']->select('CubeCart_seo_urls', false, array('path' => $path))) !== false) { in context /** * Create item URL * * @param string $path * @param bool $url */ public function getItem($path, $url = false) { if (!empty($path)) { if (($item = $GLOBALS['db']->select('CubeCart_seo_urls', false, array('path' => $path))) !== false) { $item_vars = $this->_getItemVars($item[0]['type'], $item[0]['item_id']); $_GET = (is_array($_GET)) ? array_merge($item_vars, $_GET) : $item_vars; if (isset($_GET['seo_path'])) { unset($_GET['seo_path']); } if ($url) { return $GLOBALS['storeURL'].'/index.php?'.http_build_query($_GET); } else { return true; } } else { httpredir('index.php'); } } else { httpredir('index.php'); } } /** Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted July 10, 2012 Author Share Posted July 10, 2012 Here's another one that shows up when I change Language on the front end. Fatal error: Call to a member function read() on a non-object in /home/dirtybut/public_html/plushcatalog/classes/seo.class.php on line 711 Line 711 if ($rebuild || ($this->_cat_dirs = $GLOBALS['cache']->read('seo.category.list.'.$language)) === false) { in context /** * Get categories * * @param bool $rebuild */ 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; } // Write over with translations if (($translations = $GLOBALS['db']->select('CubeCart_category_language', array('cat_id', 'cat_name'), array('language' => $language))) !== false) { foreach($translations as $translation) { $this->_cat_dirs[$translation['cat_id']]['cat_name'] = $translation['cat_name']; } } if (!empty($this->_cat_dirs)) { $GLOBALS['cache']->write($this->_cat_dirs, 'seo.category.list.'.$language); } } } } /** Quote Link to comment Share on other sites More sharing options...
bsmither Posted July 10, 2012 Share Posted July 10, 2012 In PHP, a "Call to a member ... on a non-object" means that the program is attempting to use a variable (that contains a thing that programmers call an object) that has not been properly setup before hand. In the file /controllers/controller.index.inc.php, we see that an array ($GLOBALS) is acquiring array elements, each element holding the instance (actually, an instantiation) of a class: Cache, Database, Config, etc. It is very important that these classes are instantiated in the necessary order if the programmer wants to access parts of some classes by parts of other classes. As such, Cache, Database, and Config need to be instantiated into the $GLOBALS array before any of the other classes, because these later classes use functionality found in these three very essential classes. What's a class? For our purposes, think of a class as a room full of people who know how to do related things very well -- a room full of database experts, a room full of configuration experts, etc. If I, as a Tax expert, need information from the database, I consult with a database expert as opposed to figuring out how to manage that task on my own. And the experts, or members, of each respective room are able to work together and internally share the results of their individual efforts. So, as to your error messages... can you distinguish if they are from the store front side or admin side? Have you edited any of the files in the /controllers/ folder? Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted July 10, 2012 Author Share Posted July 10, 2012 The error messages show up when I change the language as a customer and the line 255 error appears when I click around on products or put them in the basket. Please note that everything seems to be working properly! But so many people are having problems I thought shedding light on these errors might explain some of their problems. Plus I really don't like seeing "Fatal" in the log, particularly since I don't get any error message from the Dashboard! I've never even had the controller files open, but I do have mods installed, and have no idea if they've tampered with this file or not. So, pardon me for the length, and I'll post the contents of controller.index.inc.php. <?php if(!defined('CC_DS')) die('Access Denied'); //Check PHP version if (version_compare(PHP_VERSION, '5.2.3', '<')) { die('<strong>ERROR!</strong><br />CubeCart requires <a href="http://www.php.net">PHP</a> Version 5.2.3 or better. Your server is currently running PHP Version '.PHP_VERSION); } $global_template_file = 'main.php'; define('ADMIN_CP', false); // Include core functions require CC_INCLUDES_DIR.'functions.inc.php'; // Initialize Cache $GLOBALS['cache'] = Cache::getInstance(); // Initialise Database class, and fetch default configuration $GLOBALS['db'] = Database::getInstance($glob); // Initialise Config class $GLOBALS['config'] = Config::getInstance($glob); //We will not need this anymore unset($glob); $GLOBALS['config']->merge('config', '', $config_default); //Setup the cache more correctly $GLOBALS['cache']->setup(); // Initialize debug $GLOBALS['debug'] = Debug::getInstance(); //Initialize sessions $GLOBALS['session'] = Session::getInstance(); //Initialize Smarty $GLOBALS['smarty'] = new Smarty(); $GLOBALS['smarty']->compile_dir = CC_SKIN_CACHE_DIR; $GLOBALS['smarty']->config_dir = CC_SKIN_CACHE_DIR; $GLOBALS['smarty']->cache_dir = CC_SKIN_CACHE_DIR; $GLOBALS['smarty']->error_reporting = E_ALL & ~E_NOTICE; //Initialize language $GLOBALS['language'] = Language::getInstance(); //Initialize hooks $GLOBALS['hooks'] = HookLoader::getInstance(); //Initialize SEO $GLOBALS['seo'] = SEO::getInstance(); if(isset($_GET['seo_path']) && !empty($_GET['seo_path'])) { $_GET['seo_path'] = preg_replace('/(/~[a-z0-9]{1,}/)/','',$_GET['seo_path']); // Remove /~username/ from seo_path $GLOBALS['seo']->getItem($_GET['seo_path']); } //Initialize SSL $GLOBALS['ssl'] = SSL::getInstance(); //Initialize GUI $GLOBALS['gui'] = GUI::getInstance(); //Initialize Taxes $GLOBALS['tax'] = Tax::getInstance(); //Initialize catalogue $GLOBALS['catalogue'] = Catalogue::getInstance(); //Initialize cubecart $GLOBALS['cubecart'] = Cubecart::getInstance(); //Initialize user $GLOBALS['user'] = User::getInstance(); //Initialize cart $GLOBALS['cart'] = Cart::getInstance(); // Set store timezone - default to UTC date_default_timezone_set(($GLOBALS['config']->get('config', 'time_zone')) ? $GLOBALS['config']->get('config', 'time_zone') : 'UTC'); if ($GLOBALS['config']->get('config','recaptcha') && !$GLOBALS['session']->get('confirmed','recaptcha')) { require CC_INCLUDES_DIR.'lib'.CC_DS.'recaptcha'.CC_DS.'recaptchalib.php'; $GLOBALS['recaptcha_keys'] = array('captcha_private' => '6LfT4sASAAAAAKQMCK9w6xmRkkn6sl6ORdnOf83H', 'captcha_public' => '6LfT4sASAAAAAOl71cRz11Fm0erGiqNG8VAfKTHn'); $recaptcha['error'] = null; $recaptcha['confirmed'] = false; if (isset($_POST['recaptcha_response_field'])) { $resp = recaptcha_check_answer($GLOBALS['recaptcha_keys']['captcha_private'], $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']); if ($resp->is_valid) { // All good! $recaptcha['confirmed'] = true; } else { // Set the error code so that we can display it $recaptcha['error'] = $GLOBALS['language']->form['verify_human_fail']; } } $GLOBALS['session']->set('', $recaptcha, 'recaptcha'); } elseif(!$GLOBALS['session']->get('confirmed','recaptcha')) { $GLOBALS['session']->delete('', 'recaptcha'); } $_GET['_a'] = (isset($_GET['_a'])) ? $_GET['_a'] : null; $_REQUEST['_a'] = (isset($_REQUEST['_a'])) ? $_REQUEST['_a'] : null; foreach ($GLOBALS['hooks']->load('controller.index') as $hook) include $hook; $GLOBALS['language']->setTemplate(); $GLOBALS['cubecart']->loadPage(); $GLOBALS['gui']->displayCommon(); $global_template_file = 'main.php'; offline(); Quote Link to comment Share on other sites More sharing options...
Toucan Web Design Posted July 11, 2012 Share Posted July 11, 2012 They're getting pulled in right at the start, so nothing in theory generally gets run before them.. either it's not calling the controller in at all or maybesomething is overwriting the variable perhaps. Does the skin have any kind of custom ajax effects on it? Particularly for the adding to basket bit Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted July 11, 2012 Author Share Posted July 11, 2012 Thanks for weighing in on this one, Toucan. I use ShopDev's Blueprint skin on Plush Animal Shoppe, but the Collectibles Shoppe is a cosmetic modified version of kurouto skin with the same error message. I know I don't have anything fancy on the basket on the kurouto one. Plugins in place on both stores are Product Description Tabs, MailChimp, Sale Items with Images, and Sequential Order Numbers. This is very weird. When I opened the error logs, both stores showed these errors TODAY. But since I've been testing the sites this morning - I'm NOT getting the error messages!! Now I am TOTALLY confused!! Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted July 11, 2012 Author Share Posted July 11, 2012 Well, to muddy the waters even more... I logged out of Admin, closed my browser, and when I opened FireFox again with the CC login tab active - there's the error message again. Tried the same procedure again and did not get the message. It must be something a customer is triggering. No, I can trigger a similar error message by making a change on a product listing and saving it. PHP Warning: Invalid argument supplied for foreach() in /home/dirtybut/public_html/plushcatalog/admin/sources/products.index.inc.php on line 329 My host is still on PHP 5.2.17. Could that be the problem? If so, should I try to get them to upgrade, and if so to what version? I saw someone had problems upgrading to 5.4.4. Quote Link to comment Share on other sites More sharing options...
bsmither Posted July 11, 2012 Share Posted July 11, 2012 Please do this for us: In the file ini.inc.php, find: error_reporting(E_ALL ^ E_NOTICE); and add after it: ini_set('log_errors', true); ini_set('error_log','/home/dirtybut/php_errors.txt'); PHP records a trace as to what files were in play when the error occurred (I think -- at least on my server it does -- maybe because of Xdebug, hmmm...). Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted July 11, 2012 Author Share Posted July 11, 2012 OK. It's added to ini.inc.php. Where can I see the output? Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted July 11, 2012 Author Share Posted July 11, 2012 I tested repeatedly and did not get any error messages at all in the error_log file, so I took your code back off ini.inc.php and immediately had an error message. Quote Link to comment Share on other sites More sharing options...
Toucan Web Design Posted July 12, 2012 Share Posted July 12, 2012 That last error you posted may well be entirely seperate, it's to do with there not being an array of uploaded images (though it seems to think there is, and is checking for them) Looks like a bug on line 666 of filemanager.class.php for that one return (isset($file_id)) ? $file_id : true; Should return false if there's no file id's set by the looks of things, not true. So yeah, that's a different error, not related to those ones where it's not found the class data Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted July 12, 2012 Author Share Posted July 12, 2012 I don't even know enough to even be able to tell that this was not a similar error. Sorry. Right now I do NOT have bsmither's additional code added to ini.inc.php, since the messages stopped showing up in error_log with it added, and I don't know where else to look for them. If you can explain where I should look for the PHP error log, I'll add the code back and continue to test. Quote Link to comment Share on other sites More sharing options...
Toucan Web Design Posted July 12, 2012 Share Posted July 12, 2012 Could try ini_set('error_log','/home/dirtybut/public_html/plushcatalog/php_errors.txt'); Might be somewhere easier for you to find Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted July 12, 2012 Author Share Posted July 12, 2012 Done. Opened storefront and immediately received the same error message, but nothing more than was showing up in the error_log. PHP Fatal error: Call to a member function select() on a non-object in /home/dirtybut/public_html/plushcatalog/classes/seo.class.php on line 225 From Bsmither's comment: PHP records a trace as to what files were in play when the error occurred (I think -- at least on my server it does -- maybe because of Xdebug, hmmm...). Is Xdebug something I can use in some way, or is that up to the host to install? I'm still wondering if this is caused by the PHP version Hostgator is using. Since no one else has joined this thread to indicate they see this warning it makes me doubt that it's a CC bug. Quote Link to comment Share on other sites More sharing options...
SimChris Posted July 18, 2012 Share Posted July 18, 2012 I'm also getting a similar error: [Wed Jul 18 07:13:07 2012] [error] [client xxx] PHP Fatal error: Call to a member function read() on a non-object in /var/www/vhosts/MYDOMAINHERE/httpdocs/ecom/classes/seo.class.php on line 711 Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted July 18, 2012 Author Share Posted July 18, 2012 I'm also getting a similar error: [Wed Jul 18 07:13:07 2012] [error] [client xxx] PHP Fatal error: Call to a member function read() on a non-object in /var/www/vhosts/MYDOMAINHERE/httpdocs/ecom/classes/seo.class.php on line 711 What were you doing when this happened? Do you have any loss of function? As far as I can tell I don't. Quote Link to comment Share on other sites More sharing options...
SimChris Posted April 4, 2013 Share Posted April 4, 2013 Getting these again: appear to be related to my being logged in as admin and then going to view pages in the store in browser. PHP Fatal error: Call to a member function select() on a non-object in /var/www/vhosts/mysitenamehere.com/httpdocs/ecom/classes/seo.class.php on line 719, referer: http://mysitenamehere/ Quote Link to comment Share on other sites More sharing options...
bsmither Posted April 4, 2013 Share Posted April 4, 2013 For some reason, the Database class has been de-instantiated. After a PHP error (from somewhere else), PHP begins to shut down -- the same as if PHP had no more script to execute after sending the HTML page out to your browser. When PHP is shutting down, PHP will begin executing the _destruct() method of the classes that have been instantiated. There is no definite way to determine in what order the classes will be destroyed. Finding out why the Database class is getting destroyed is difficult. But we can force the class to be re-instantiated if necessary, and then see what else blows up. In the file /classes/seo.class.php, just after the private function _getCategoryList line , add:if (!isset($GLOBALS['db']) || !is_object($GLOBALS['db'])) { $GLOBALS['db'] = Database::getInstance(); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.