Results 1 to 8 of 8
  1. #1
    Join Date
    Dec 2013
    Location
    Adelaide, South Australia
    Posts
    12
    Plugin Contributions
    0

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

  2. #2
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    6,589
    Plugin Contributions
    260

    Default 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
    That Software Guy, Plugin Moderator. Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Contributions: Quantity Discounts, Better Together, SMS on Sale, Gift Wrap at Checkout, and more.

  3. #3
    Join Date
    Jul 2012
    Posts
    14,370
    Plugin Contributions
    17

    Default 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.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...
    Upgraded to Zen Cart V1.5.3 from V1.5.1 from V1.5.0 from V1.3.9h

  4. #4
    Join Date
    Jan 2004
    Posts
    65,286
    Blog Entries
    7
    Plugin Contributions
    227

    Default 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) {
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    6,589
    Plugin Contributions
    260

    Default Re: Parameter must be an array or an object that implements Countable

    Exact code details can be seen at https://github.com/zencart/zencart/pull/1900/files
    Last edited by DrByte; 14 Dec 2018 at 08:56 PM. Reason: Update with github link
    That Software Guy, Plugin Moderator. Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Contributions: Quantity Discounts, Better Together, SMS on Sale, Gift Wrap at Checkout, and more.

  6. #6
    Join Date
    Dec 2013
    Location
    Adelaide, South Australia
    Posts
    12
    Plugin Contributions
    0

    Default Re: Parameter must be an array or an object that implements Countable

    Hi Mc,

    Without demo products. :)

  7. #7
    Join Date
    Dec 2013
    Location
    Adelaide, South Australia
    Posts
    12
    Plugin Contributions
    0

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

  8. #8
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    6,589
    Plugin Contributions
    260

    Default 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. :)
    That Software Guy, Plugin Moderator. Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Contributions: Quantity Discounts, Better Together, SMS on Sale, Gift Wrap at Checkout, and more.

 

 

Similar Threads

  1. Replies: 8
    Last Post: 28 Dec 2018, 06:25 AM
  2. Replies: 11
    Last Post: 21 Dec 2018, 09:06 PM
  3. v154 PHP Warning: extract() expects parameter 1 to be array
    By JoeH in forum General Questions
    Replies: 2
    Last Post: 15 May 2018, 06:44 PM
  4. PHP Warning: addslashes() expects parameter 1 to be string, array given
    By schoolboy in forum All Other Contributions/Addons
    Replies: 11
    Last Post: 10 May 2013, 02:19 PM
  5. v139e PHP Warning: strlen() expects parameter 1 to be string, array given in
    By irishshopper in forum Basic Configuration
    Replies: 4
    Last Post: 7 Mar 2013, 08:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR