shipping modules and PHP 7.2
I originally thought this was a template related issue, unable to track it down.
I completed a vanilla install, went through checkout process, no debug files generated.
Installed ups_v2019_01_08
upon clicking modules > shipping
the following was created
Code:
[13-Jan-2019 18:13:29 America/New_York] Request URI: /zca_templates/zca_tpl_demo_6/***/modules.php?set=shipping, IP address: ***
#1 ups->__construct() called at [/home/***/public_html/zca_templates/zca_tpl_demo_6/***/modules.php:195]
--> PHP Warning: Use of undefined constant MODULE_SHIPPING_UPS_SORT_ORDER - assumed 'MODULE_SHIPPING_UPS_SORT_ORDER' (this will throw an Error in a future version of PHP) in /home/***/public_html/zca_templates/zca_tpl_demo_6/includes/modules/shipping/ups.php on line 61.
[13-Jan-2019 18:13:29 America/New_York] Request URI: /zca_templates/zca_tpl_demo_6/***/modules.php?set=shipping, IP address: ***
#1 ups->__construct() called at [/home/***/public_html/zca_templates/zca_tpl_demo_6/***/modules.php:195]
--> PHP Warning: Use of undefined constant MODULE_SHIPPING_UPS_TAX_CLASS - assumed 'MODULE_SHIPPING_UPS_TAX_CLASS' (this will throw an Error in a future version of PHP) in /home/***/public_html/zca_templates/zca_tpl_demo_6/includes/modules/shipping/ups.php on line 63.
[13-Jan-2019 18:13:29 America/New_York] Request URI: /zca_templates/zca_tpl_demo_6/***l/modules.php?set=shipping, IP address: ***
#1 ups->__construct() called at [/home/***/public_html/zca_templates/zca_tpl_demo_6/***/modules.php:195]
--> PHP Warning: Use of undefined constant MODULE_SHIPPING_UPS_TAX_BASIS - assumed 'MODULE_SHIPPING_UPS_TAX_BASIS' (this will throw an Error in a future version of PHP) in /home/***/public_html/zca_templates/zca_tpl_demo_6/includes/modules/shipping/ups.php on line 64.
[13-Jan-2019 18:13:29 America/New_York] Request URI: /zca_templates/zca_tpl_demo_6/***/modules.php?set=shipping, IP address: ***
#1 ups->__construct() called at [/home/***/public_html/zca_templates/zca_tpl_demo_6/***/modules.php:195]
--> PHP Warning: Use of undefined constant MODULE_SHIPPING_UPS_STATUS - assumed 'MODULE_SHIPPING_UPS_STATUS' (this will throw an Error in a future version of PHP) in /home/***/public_html/zca_templates/zca_tpl_demo_6/includes/modules/shipping/ups.php on line 68.
[13-Jan-2019 18:13:29 America/New_York] Request URI: /zca_templates/zca_tpl_demo_6/***/modules.php?set=shipping, IP address: ***
#1 ups->__construct() called at [/home/***/public_html/zca_templates/zca_tpl_demo_6/***/modules.php:195]
--> PHP Warning: Use of undefined constant MODULE_SHIPPING_UPS_STATUS - assumed 'MODULE_SHIPPING_UPS_STATUS' (this will throw an Error in a future version of PHP) in /home/***/public_html/zca_templates/zca_tpl_demo_6/includes/modules/shipping/ups.php on line 72.
For the catalog side while using the shipping estimator, the following was created:
Code:
[13-Jan-2019 18:45:31 America/New_York] Request URI: /zca_templates/zca_tpl_demo_6/index.php?main_page=popup_shipping_estimator, IP address: ***
#1 sizeof() called at [/home/***/public_html/zca_templates/zca_tpl_demo_6/includes/classes/shipping.php:186]
#2 shipping->cheapest() called at [/home/***/public_html/zca_templates/zca_tpl_demo_6/includes/modules/shipping_estimator.php:210]
#3 require(/home/***/public_html/zca_templates/zca_tpl_demo_6/includes/modules/shipping_estimator.php) called at [/home/***/public_html/zca_templates/zca_tpl_demo_6/includes/templates/template_default/popup_shipping_estimator/tpl_main_page.php:16]
#4 require(/home/***/public_html/zca_templates/zca_tpl_demo_6/includes/templates/template_default/popup_shipping_estimator/tpl_main_page.php) called at [/home/***/public_html/zca_templates/zca_tpl_demo_6/index.php:97]
--> PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in /home/***/public_html/zca_templates/zca_tpl_demo_6/includes/classes/shipping.php on line 186.
[13-Jan-2019 18:45:31 America/New_York] Request URI: /zca_templates/zca_tpl_demo_6/index.php?main_page=popup_shipping_estimator, IP address: 71.176.114.218
#1 sizeof() called at [/home/***/public_html/zca_templates/zca_tpl_demo_6/includes/templates/template_default/templates/tpl_modules_shipping_estimator.php:134]
#2 require(/home/***/public_html/zca_templates/zca_tpl_demo_6/includes/templates/template_default/templates/tpl_modules_shipping_estimator.php) called at [/home/zcaddit1/public_html/zca_templates/zca_tpl_demo_6/includes/modules/shipping_estimator.php:256]
#3 require(/home/***/public_html/zca_templates/zca_tpl_demo_6/includes/modules/shipping_estimator.php) called at [/home/***/public_html/zca_templates/zca_tpl_demo_6/includes/templates/template_default/popup_shipping_estimator/tpl_main_page.php:16]
#4 require(/home/***/public_html/zca_templates/zca_tpl_demo_6/includes/templates/template_default/popup_shipping_estimator/tpl_main_page.php) called at [/home/zcaddit1/public_html/zca_templates/zca_tpl_demo_6/index.php:97]
--> PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in /home/***/public_html/zca_templates/zca_tpl_demo_6/includes/templates/template_default/templates/tpl_modules_shipping_estimator.php on line 134.
The same using fedex_web_services_1_7_6 by numinix
I spent hours thinking this was a template issue/bug :censored:
Re: 1.5.6a shipping modules
Moving this out of the Bug Reports area, since it's related to addons, and is caused by PHP 7.2 issues, not by new code in Zen Cart v1.5.6
Re: shipping modules and PHP 7.2
That said, I've posted an update to the UPS module, for improved PHP 7.2 compatibility.
Re: shipping modules and PHP 7.2
USPS causes similar DEBUG.
Code:
[13-Jan-2019 17:56:28 America/Los_Angeles] Request URI: /156/index.php?main_page=popup_shipping_estimator, IP address: 98.146.xxx.yyy#1 sizeof() called at [/home/cPanel/public_html/156/includes/classes/shipping.php:186]
#2 shipping->cheapest() called at [/home/cPanel/public_html/156/includes/modules/shipping_estimator.php:210]
#3 require(/home/cPanel/public_html/156/includes/modules/shipping_estimator.php) called at [/home/cPanel/public_html/156/includes/templates/template_default/popup_shipping_estimator/tpl_main_page.php:16]
#4 require(/home/cPanel/public_html/156/includes/templates/template_default/popup_shipping_estimator/tpl_main_page.php) called at [/home/cPanel/public_html/156/index.php:97]
--> PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in /home/cPanel/public_html/156/includes/classes/shipping.php on line 186.
[13-Jan-2019 17:56:28 America/Los_Angeles] Request URI: /156/index.php?main_page=popup_shipping_estimator, IP address: 98.146.xxx.yyy
#1 sizeof() called at [/home/cPanel/public_html/156/includes/templates/bootstrap/templates/tpl_modules_shipping_estimator.php:153]
#2 require(/home/cPanel/public_html/156/includes/templates/bootstrap/templates/tpl_modules_shipping_estimator.php) called at [/home/cPanel/public_html/156/includes/modules/shipping_estimator.php:256]
#3 require(/home/cPanel/public_html/156/includes/modules/shipping_estimator.php) called at [/home/cPanel/public_html/156/includes/templates/template_default/popup_shipping_estimator/tpl_main_page.php:16]
#4 require(/home/cPanel/public_html/156/includes/templates/template_default/popup_shipping_estimator/tpl_main_page.php) called at [/home/cPanel/public_html/156/index.php:97]
--> PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in /home/cPanel/public_html/156/includes/templates/bootstrap/templates/tpl_modules_shipping_estimator.php on line 153.
Re: shipping modules and PHP 7.2
Quote:
Originally Posted by
RixStix
USPS causes similar DEBUG.
Code:
[13-Jan-2019 17:56:28 America/Los_Angeles] Request URI: /156/index.php?main_page=popup_shipping_estimator, IP address: 98.146.xxx.yyy#1 sizeof() called at [/home/cPanel/public_html/156/includes/classes/shipping.php:186]
#2 shipping->cheapest() called at [/home/cPanel/public_html/156/includes/modules/shipping_estimator.php:210]
#3 require(/home/cPanel/public_html/156/includes/modules/shipping_estimator.php) called at [/home/cPanel/public_html/156/includes/templates/template_default/popup_shipping_estimator/tpl_main_page.php:16]
#4 require(/home/cPanel/public_html/156/includes/templates/template_default/popup_shipping_estimator/tpl_main_page.php) called at [/home/cPanel/public_html/156/index.php:97]
--> PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in /home/cPanel/public_html/156/includes/classes/shipping.php on line 186.
i resolved the above error by adding the following code into:
/includes/classes/shipping.php
at line 186...
PHP Code:
$quotes = $GLOBALS[$class]->quotes;
//new code
if (!is_array($quotes['methods'])) {
return;
}
//end new code
$size = sizeof($quotes['methods']);
Re: shipping modules and PHP 7.2
Quote:
Originally Posted by
carlwhat
i resolved the above error by adding the following code into:
/includes/classes/shipping.php
at line 186...
PHP Code:
$quotes = $GLOBALS[$class]->quotes;
//new code
if (!is_array($quotes['methods'])) {
return;
}
//end new code
$size = sizeof($quotes['methods']);
Given that many modules seem to send back empty responses, we should probably patch for that. Feel free to PR. Although I prefer if (empty()) as opposed to if (!is_array()) in this case (... unless you've found a reason to expect a valid string or integer response).