Zen Cart Logo
Forums / Bug Reports / [Done v1] ezpages logs - PHP Warning: Parameter must be an array or an object that...

[Done v1] ezpages logs - PHP Warning: Parameter must be an array or an object that...

Locked

Views: 6,241

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
14 Dec 2018, 6:42 AM
#1
webmanstudios avatar

webmanstudios

New Zenner

Join Date:
Dec 2013
Location:
Adelaide, South Australia
Posts:
29
Plugin Contributions:
0

[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. :)

14 Dec 2018, 6:53 AM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,711
Plugin Contributions:
56

Re: [Done v1] ezpages logs - PHP Warning: Parameter must be an array or an object that...

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

14 Dec 2018, 7:36 AM
#3
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: [Done v1] ezpages logs - PHP Warning: Parameter must be an array or an object that...

Curious, when say squeaky clean install, is this with/without demo products?

Also, in the repair, doesn't that line effectively become:

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.

14 Dec 2018, 6:54 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Done v1] ezpages logs - PHP Warning: Parameter must be an array or an object that...

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

  if ($pages_query->RecordCount()>0) {
    $rows = 0;
[B]    $page_query_list_header = array();[/B]
    foreach ($pages_query as $page_query) {

/includes/modules/ezpages_bar_footer.php

  if ($pages_query->RecordCount()>0) {
    $rows = 0;
[B]    $page_query_list_footer = array();[/B]
    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:

      $title =  BOX_HEADING_EZPAGES;
      $box_id =  'ezpages';
      $rows = 0;
[B]      $page_query_list_sidebox = array();[/B]
      foreach ($pages_query as $page_query) {
14 Dec 2018, 7:08 PM
#5
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,711
Plugin Contributions:
56

Re: [Done v1] ezpages logs - PHP Warning: Parameter must be an array or an object that...

Exact code details can be seen at https://github.com/zencart/zencart/pull/1900/files

15 Dec 2018, 1:44 AM
#6
webmanstudios avatar

webmanstudios

New Zenner

Join Date:
Dec 2013
Location:
Adelaide, South Australia
Posts:
29
Plugin Contributions:
0

Re: [Done v1] ezpages logs - PHP Warning: Parameter must be an array or an object that...

Hi Mc,

Without demo products. :)

15 Dec 2018, 1:59 AM
#7
webmanstudios avatar

webmanstudios

New Zenner

Join Date:
Dec 2013
Location:
Adelaide, South Australia
Posts:
29
Plugin Contributions:
0

Re: [Done v1] ezpages logs - PHP Warning: Parameter must be an array or an object that...

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 ```
if (!empty($var_linksList)) {


Thanks again. :)
16 Dec 2018, 3:00 PM
#8
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,711
Plugin Contributions:
56

Re: [Done v1] ezpages logs - PHP Warning: Parameter must be an array or an object that...

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. :)