Support » Plugin: Collapsing Categories » php warning is filling error.log on WP 5.0.1

  • mbeerli

    (@mbeerli)


    Yes I know the plugin is not yet up to 5.0 compatible but this has been going on since about 5 weeks.
    The warning happens about every 90s and is filling the log file

    [16-Dec-2018 05:06:15 UTC] PHP Warning: count(): Parameter must be an array or an object that implements Countable in /home/…/wp-content/plugins/collapsing-categories/collapscatlist.php on line 508
    [16-Dec-2018 05:07:30 UTC] PHP Warning: count(): Parameter must be an array or an object that implements Countable in /home/…/wp-content/plugins/collapsing-categories/collapscatlist.php on line 508
    [16-Dec-2018 05:08:56 UTC] PHP Warning: count(): Parameter must be an array or an object that implements Countable in /home/…/wp-content/plugins/collapsing-categories/collapscatlist.php on line 508
    [16-Dec-2018 05:09:05 UTC] PHP Warning: count(): Parameter must be an array or an object that implements Countable in /home/…/wp-content/plugins/collapsing-categories/collapscatlist.php on line 508
    [16-Dec-2018 05:11:26 UTC] PHP Warning: count(): Parameter must be an array or an object that implements Countable in /home/…/wp-content/plugins/collapsing-categories/collapscatlist.php on line 508
    [16-Dec-2018 05:12:40 UTC] PHP Warning: count(): Parameter must be an array or an object that implements Countable in /home/…/wp-content/plugins/collapsing-categories/collapscatlist.php on line 508

Viewing 7 replies - 1 through 7 (of 7 total)
  • I was getting a similar warning after upgrading from PHP7.0 to PHP7.2. In my case, the error was manifesting itself on the home page, in the collapsible categories widget.

    The code in question, starting at line 508, is:

    $totalPostCount=count($posts);
    if ($totalPostCount>5000) {
    $options[‘showPosts’]=false;
    $showPosts=false;
    }

    This is the only mention of $totalPostCount in the module, so I commented line 508 out and replaced it with:

    $totalPostCount=0;

    The error then goes away. Hopefully this will not cause me any problems down the line (my total posts are around 2,000 at the moment).

    If you are not comfortable editing PHP code on your WordPress site, then I’m afraid I have no simple solution!

    Good luck,
    Brian.

    Hello Brian,
    thanks for the feedback. I have no issue with changing php code. I was hoping for a more permanent solution from the author.

    Ross Wintle

    (@magicroundabout)

    Just adding a vote for fixing this. I just updated a dev site to PHP7.2 and had this warning. It’s a simple fix!

    Any news on fixing the issue?
    I am on php 7.2.6

    The error.log file grows within days over 5000 kb

    In order to analyse the file you have todo a reverse grep
    on ‘collapscatlist.php on line 508’

    Now on WP 5.1, even though the plugin is only tested to 4.9.9
    Still the same warning filling the error.log file.
    Any fix coming out soon?

    Deleted the php error_log again. Only 10MB in size full with the error
    [05-May-2019 09:37:41 UTC] PHP Warning: count(): Parameter must be an array or an object that implements Countable in /home/../wp-content/plugins/collapsing-categories/collapscatlist.php on line 508

    Hi,

    You can solve this problem by casting the variable $post into an array.

    Replace the line 508 $totalPostCount=count($posts);
    With these line here below

    $arrayFoo = (array) $posts;
    $totalPostCount=count($arrayFoo);

    My PHP version is 7.2
    Hope this help some people.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.