Jump to content

PHP Fatal error: Call to a member function select() on a non-object i


designinggal

Recommended Posts

Please make these edits in seo.class.php:

Line 735: $GLOBALS['db'] to Database::getInstance()

Line 741: $GLOBALS['db'] to Database::getInstance()

Line 748: $GLOBALS['cache'] to Cache::getInstance()

 

Please make these edits in cart.class.php:

Line 1009: $GLOBALS['session'] to Session::getInstance()

Line 1012: $GLOBALS['config'] to Config::getInstance()

Line 1014: $GLOBALS['user'] to User::getInstance()

 

This has been reported.

 

The reason for the error is that when PHP loads and instantiates class objects to use them, there is no way to predict in what order these objects are destroyed when PHP is shutting down. Each class can have a routine which it is programmed to perform when shutting down. In one such case, the Cart class, when being destroyed, saves the current basket contents - requiring the Database, Session, Config, and User classes.

 

The developers of PHP say that there is no way to predict in what order the classes are destroyed, but they do not say why. I am going to guess that much of this activity depends on how PHP was compiled for your operating system, the version of PHP, and other environmental factors that are near-impossible to replicate on someone else's development platform.

Link to comment
Share on other sites

Yes, the CubeCart code uses $GLOBALS['name_of_class'] everywhere, except where it causes a problem. And the only time it causes a problem is when PHP is shutting down (after having completed the script it was told to run initially) and destroying objects and erasing variables. So, this problem of trying to use a class object when PHP has already destroyed it will happen, but rarely.

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...