Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

PHP error upgrading to 7.3


Recommended Posts

Hi, 

Im hoping this is a quick question with an easy answer...

I have just updated my server from 5.6 to 7.3 and am just experiencing an error I can't work out how to fix...

the error is;

PHP Warning:  sizeof(): Parameter must be an array or an object that implements Countable in.....

and the line of code in question is;

                for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {

Any help would be appreciated.

Link to comment
Share on other sites

The easy answer is: turn off displaying warnings.

It's a warning not an error until some future version of php.

in includes/application_top.php find:

  error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT);
  ini_set('display_errors',1);

on a live site you may not want to display any error messages to the public, in which case in the second line change 1 to 0 (zero) or if you want only to suppress warnings, change the first line to

  error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_WARNING);

 

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Link to comment
Share on other sites

It's throwing that warning because the order instance it's trying to process has no products in it. That doesn't sound like a valid order to me, and could well indicate a problem with the construction of the order instance. If it's an existing order read from the database, check the database order to make sure it was created properly.

 

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Link to comment
Share on other sites

for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {

by

if (is_array($order->products) {
for ($i=0, $n=count($order->products); $i<$n; $i++) {

 


Regards
-----------------------------------------
Loïc

Contact me by skype for business
Contact me @gyakutsuki for an answer on the forum

 

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...