Parameter must be an array or an object that implements Countable in fec.php
I am using fast and easy checkout. I am getting the following errors when i upgraded to php7.2
[29-Dec-2019 02:45:53 America/New_York] PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in /home/inverter/public_html/includes/classes/observers/class.fec.php on line 101
[29-Dec-2019 12:08:19 America/New_York] PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in /home/inverter/public_html/includes/classes/observers/class.fec.php on line 111
[29-Dec-2019 12:09:34 America/New_York] PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in /home/inverter/public_html/includes/classes/observers/class.fec.php on line 111
I have enclosed the class.fec.php file where the errors are coming from. If someone could assist me in getting this fixed
PHP Code:
<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce |
// +----------------------------------------------------------------------+
// | Copyright (c) 2007-2008 Numinix Technology http://www.numinix.com |
// | |
// | Portions Copyright (c) 2003-2006 Zen Cart Development Team |
// | http://www.zen-cart.com/index.php |
// | |
// | Portions Copyright (c) 2003 osCommerce |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.zen-cart.com/license/2_0.txt. |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to |
// | [email protected] so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// $Id: class.fec.php 109 2010-04-28 05:47:55Z numinix $
//
/**
* Observer class used to redirect to the FEC page
*
*/
class FECObserver extends base
{
function FECObserver()
{
global $zco_notifier;
$zco_notifier->attach($this, array('NOTIFY_HEADER_START_CHECKOUT_SHIPPING'));
$zco_notifier->attach($this, array('NOTIFY_HEADER_END_CHECKOUT_PAYMENT'));
}
function update(&$class, $eventID, $paramsArray) {
global $messageStack;
if (FEC_STATUS == 'true') {
$error = false;
if ($_GET['main_page'] == FILENAME_CHECKOUT_PAYMENT and sizeof($messageStack->messages) > 0) {
$error = true;
for ($i=0, $n=sizeof($messageStack->messages); $i<$n; $i++) {
if ($messageStack->messages[$i]['class'] == 'checkout_payment') {
$checkout_payment_output[] = $messageStack->messages[$i];
}
if ($messageStack->messages[$i]['class'] == 'redemptions') {
$redemptions_output[] = $messageStack->messages[$i];
}
}
$messageStack->reset();
if (sizeof($checkout_payment_output) > 0) {
for ($i=0, $n=sizeof($checkout_payment_output); $i<$n; $i++) {
$messageStack->add_session('checkout_payment', strip_tags($checkout_payment_output[$i]['text']), 'error');
}
}
if (sizeof($redemptions_output) > 0) {
for ($i=0, $n=sizeof($redemptions_output); $i<$n; $i++) {
$messageStack->add_session('redemptions', strip_tags($redemptions_output[$i]['text']), 'caution');
}
}
}
if ($_GET['credit_class_error']) {
$error = true;
$messageStack->add_session('checkout_payment', htmlspecialchars(urldecode($_GET['credit_class_error'])), 'error');
}
if ($error) {
zen_redirect(zen_href_link(FILENAME_CHECKOUT, "fecaction=null", 'SSL'));
} else {
zen_redirect(zen_href_link(FILENAME_CHECKOUT, '', 'SSL'));
}
}
}
}
// eof
Re: Parameter must be an array or an object that implements Countable in fec.php
Perhaps (?) at the top of the update method, initialize those two arrays:
Code:
$checkout_payment_output = array();
$redemptions_output = array();
Re: Parameter must be an array or an object that implements Countable in fec.php
not sure what you mean by
$checkout_payment_output = array();
$redemptions_output = array();.
DO i put that at the top of the page?
Re: Parameter must be an array or an object that implements Countable in fec.php
after
PHP Code:
function update(&$class, $eventID, $paramsArray) {
global $messageStack;
Re: Parameter must be an array or an object that implements Countable in fec.php
i think I got a little lost here. WHere do i put the code
$checkout_payment_output = array();
$redemptions_output = array();.
and this
function update(&$class, $eventID, $paramsArray) {
global $messageStack;
Re: Parameter must be an array or an object that implements Countable in fec.php
i see this is what i did
function update(&$class, $eventID, $paramsArray) {
global $messageStack;
$checkout_payment_output = array();
$redemptions_output = array();
if (FEC_STATUS == 'true') {
Re: Parameter must be an array or an object that implements Countable in fec.php
and did that fix the issue?
Re: Parameter must be an array or an object that implements Countable in fec.php
seems to have solved the issue. I will followup if i see any issue in the log
Upgrade notice [FEC]Parameter must be an array or an object that implements Countable
Zencart 1.5.7
Php 7.4
I am currently in the upgrade process from 5.6 to 5.7.
I use FEC fast and easy checkout. I cant seem to solve this error. If some could help that would be great.
Error
HTML Code:
--> PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in C:\xampp\htdocs\xxxxxx.com\includes\templates\theme871\templates\tpl_checkout_stacked.php on line 313.
This is the line of code on line 313. This is where i am getting confused. I am not sure how to make the changes.
Code:
else {
for ($j=0, $n2=sizeof($quotes[$i]['methods']); $j<$n2; $j++) {
this is just the full piece of code in case i missed something
Code:
<?php }
else {
for ($j=0, $n2=sizeof($quotes[$i]['methods']); $j<$n2; $j++) {
// set the radio button to be checked if it is the method chosen
$checked = (($quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'] == $_SESSION['shipping']['id']) ? true : false);
if ( ($checked == true) || ($n == 1 && $n2 == 1) ) {
//echo ' <div id="defaultSelected" class="moduleRowSelected">' . "\n";
//} else {
//echo ' <div class="moduleRow">' . "\n";
}
?>
<?php
Re: Upgrade Question - Parameter must be an array or an object that implements Counta
Need code prior to that as '$quotes[$i]['methods']' is not "properly" set to be an array or something "countable"... It could be that it isn't set at all, but wouldn't really know unless the earlier code were reviewed...