[Done v1] ezpages logs - PHP Warning: Parameter must be an array or an object that...
Hi All,
Not sure what the following means but thought i'd see if it is anything of concern.
On checking my log files after a squeaky clean install I found these Warning entries in the log folder:
[14-Dec-2018 17:34:19 Australia/Melbourne] Request URI: /shop/index.php?main_page=index, IP address: ***.***.***.***
#1 sizeof() called at [/***/***/***/***/includes/templates/responsive_classic/templates/tpl_ezpages_bar_header.php:19]
#2 require(/***/***/***/***/includes/templates/responsive_classic/templates/tpl_ezpages_bar_header.php) called at [/***/***/***/***/includes/templates/responsive_classic/common/tpl_header.php:210]
#3 require(/***/***/***/***/includes/templates/responsive_classic/common/tpl_header.php) called at [/***/***/***/***/includes/templates/responsive_classic/common/tpl_main_page.php:119]
#4 require(/***/***/***/***/includes/templates/responsive_classic/common/tpl_main_page.php) called at [/***/***/***/***/index.php:97]
[14-Dec-2018 17:34:19 Australia/Melbourne] PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in /***/***/***/***/includes/templates/responsive_classic/templates/tpl_ezpages_bar_header.php on line 19
[14-Dec-2018 17:34:19 Australia/Melbourne] Request URI: /shop/index.php?main_page=index, IP address: ***.***.***.***
#1 sizeof() called at [/***/***/***/***/includes/templates/responsive_classic/templates/tpl_ezpages_bar_footer.php:19]
#2 require(/***/***/***/***/includes/templates/responsive_classic/templates/tpl_ezpages_bar_footer.php) called at [/***/***/***/***/includes/templates/responsive_classic/common/tpl_footer.php:32]
#3 require(/***/***/***/***/includes/templates/responsive_classic/common/tpl_footer.php) called at [/***/***/***/***/includes/templates/responsive_classic/common/tpl_main_page.php:218]
#4 require(/***/***/***/***/includes/templates/responsive_classic/common/tpl_main_page.php) called at [/***/***/***/***/index.php:97]
[14-Dec-2018 17:34:19 Australia/Melbourne] PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in /***/***/***/***/includes/templates/responsive_classic/templates/tpl_ezpages_bar_footer.php on line 19
The same warning files are created every time a page loads.
Thank you. :)
Re: Parameter must be an array or an object that implements Countable
Change
<?php if (sizeof($var_linksList) >= 1) { ?>
to
<?php if (isset($var_linksList) && sizeof($var_linksList) >= 1) { ?>
on includes/templates/responsive_classic/templates/tpl_ezpages_bar_footer.php on line 19
Re: Parameter must be an array or an object that implements Countable
Curious, when say squeaky clean install, is this with/without demo products?
Also, in the repair, doesn't that line effectively become:
Code:
if (!empty($var_linksList)) {
Though still wonder if there is an importance to $var_linksList being an array type/style variable which isn't tested by the original nor proposed code.
Re: Parameter must be an array or an object that implements Countable
The !empty() approach that mc12345678 suggested is the tidiest syntax, and is a suitable change.
However the deeper core code fix, which would mean not needing to touch the template files, is to edit these 3 files adding a new line, as shown:
/includes/modules/ezpages_bar_header.php
Code:
if ($pages_query->RecordCount()>0) {
$rows = 0;
$page_query_list_header = array();
foreach ($pages_query as $page_query) {
/includes/modules/ezpages_bar_footer.php
Code:
if ($pages_query->RecordCount()>0) {
$rows = 0;
$page_query_list_footer = array();
foreach ($pages_query as $page_query) {
If you have an override (ie, same filename inside /includes/modules/YOUR_TEMPLATE_NAME_HERE folder), then make the same change there too.
Same with the sidebox:
/includes/modules/sideboxes/ezpages.php and any overrides:
Code:
$title = BOX_HEADING_EZPAGES;
$box_id = 'ezpages';
$rows = 0;
$page_query_list_sidebox = array();
foreach ($pages_query as $page_query) {
Re: Parameter must be an array or an object that implements Countable
Re: Parameter must be an array or an object that implements Countable
Hi Mc,
Without demo products. :)
Re: Parameter must be an array or an object that implements Countable
Hi All,
Thank you for your help and suggested changes. :)
I tried Dr Bytes solution but it didin't seem to fix the issue and I was still receiving log error file every time the page loaded.
I then tried the
Code:
if (!empty($var_linksList)) {
and this stopped the error log files. YAY!
Thanks again. :)
Re: Parameter must be an array or an object that implements Countable
I would still be in favor of doing the template change in addition to the core file change as an anti-bugging measure. Thanks to MC# for tightening up my code. :)