Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Call to undefined method error - Please help


freakystreak

Recommended Posts

I have been given the task of migrating a current live osCommerce website, version 2.3.4 from a server running PHP 5.3.3 to a server running PHP 7.0.33. I understand that I should really upgrade to the latest (Frozen) version of osCommerce but this live site has many custom coded features and addons that will need to be re-written to be added to the latest version and I only have a short time before the old server is switched off.  I have a test environment set up on the new server and I've moved copies of the existing database and files to create the error testing site. I have managed to correct many issues by renaming the class function name to '__construct'. My admin side seems to be working fine, however on the store front I'm getting this error whenever a product is added to the cart or any message is to be displayed : 

Fatal error: Uncaught Error: Call to undefined method messageStack::alertBlock() in /home/xxxxx/public_html/xxxxx/includes/classes/message_stack.php:66 Stack trace: #0 /home/xxxx/public_html/xxxx/includes/modules/product_listing.php(4): messageStack->output('product_action') #1 /home/xxxx/public_html/xxxxx/index.php(227): include('/home/xxxx...') #2 {main} thrown in /home/xxxx/public_html/xxxx/includes/classes/message_stack.php on line 66

The line in question is:

return $this->alertBlock($output);

Does anyone have any ideas how I can fix this? I would appreciate any suggestions on how to sort this out.

Many thanks.

 

Ah, the world wide web. What a wonderful place.

Link to comment
Share on other sites

  • 3 weeks later...

messageStack extends alertblock, make sure that's at the top of your class i.e. class messageStack extends alertBlock {

Then make sure includes/classes/alertbox.php is being included in application_top.php i.e.

 require('includes/classes/alertbox.php');
 require('includes/classes/message_stack.php');
 $messageStack = new messageStack;

If it still don't work, hit it again!

Senior PHP Dev with 18+ years of commercial experience for hire, all requirements considered, see profile for more information.

Is your version of osC up to date? You'll find the latest osC version (the community-supported responsive version) here.

Link to comment
Share on other sites

Quote

I have managed to correct many issues by renaming the class function name to '__construct'.

Blindly renaming class function names to __construct may cause problems. See the discussion in

In some cases you may need to leave class function name and build either a dummy __construct or one that calls class function name. You could get a copy of Frozen and look at the class code to see what was done there.

If this is just a temporary bridge until you can get onto Frozen (or even Edge), you might want to consider simply suppressing "deprecated" warnings. There's plenty of discussion on this forum. It's not a permanent fix, as eventually something will be removed from PHP and cause serious errors, but it could tide you over until you have an up-to-date osC running (2.3.4 is quite long of tooth).

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...