Getting Error message E_WARNING: count(): Parameter must be an array or an object that implements Countable

Hi

I have had to upgrade to PHP7.2 as version 7 is at end of life and not being supported any more soon.

I use Newrelic.com service to monitor my site and since updating I am getting a 25% error rate perviously I only had 0.05% errors.

I have spoken to my host and they have said that the errors could be due to old php code in the theme. You may want to reach out to the theme developer on this one.

Here is an example of the error message I get:
Error message
E_WARNING: count(): Parameter must be an array or an object that implements Countable

in count called at /nas/content/live/--------/wp-includes/post-template.php (284)
in get_the_content called at /nas/content/live/--------/wp-includes/formatting.php (3308)
in wp_trim_excerpt called at ? (?)
in call_user_func_array called at /nas/content/live/--------/wp-includes/class-wp-hook.php (288)
in WP_Hook::apply_filters called at /nas/content/live/--------/wp-includes/plugin.php (203)
in apply_filters called at /nas/content/live/--------/wp-includes/post-template.php (397)
in get_the_excerpt called at /nas/content/live/--------/wp-content/themes/pro/framework/functions/frontend/social.php (89)
in x_social_meta called at ? (?)
in call_user_func_array called at /nas/content/live/--------/wp-includes/class-wp-hook.php (286)
in WP_Hook::apply_filters called at /nas/content/live/--------/wp-includes/class-wp-hook.php (310)
in WP_Hook::do_action called at /nas/content/live/--------/wp-includes/plugin.php (453)
in do_action called at /nas/content/live/--------/wp-includes/general-template.php (2614)
in wp_head called at /nas/content/live/--------/wp-content/themes/child-pro/framework/views/header/base.php (39)
in include called at /nas/content/live/--------/wp-content/themes/pro/framework/functions/frontend/view-routing.php (182)
in X_View_Router::render called at /nas/content/live/--------/wp-content/themes/pro/framework/functions/frontend/view-routing.php (55)
in x_get_view called at /nas/content/live/--------/wp-content/themes/pro/header.php (9)
in require_once called at /nas/content/live/--------/wp-includes/template.php (688)
in load_template called at /nas/content/live/--------/wp-includes/template.php (647)
in locate_template called at /nas/content/live/--------/wp-includes/general-template.php (41)
in get_header called at /nas/content/live/--------/wp-content/themes/pro/framework/views/ethos/template-blank-4.php (9)

I have updated my theme to PRO 2.4.6 and am running WP 5.0.3

Thanks
Tim

Hey Tim,

Thanks for reporting. Those are warning messages only and it can’t affect your site. As you can see, WordPress itself also triggers the warning.

But to be sure, can you try switching to the default theme and see what warnings are generated. We will need to know what specific warnings are generated by Pro so we can post it to our issue tracker.

Previously for example, a user reported that class-app-boot.php is generating the same warning that you posted and later it was updated so rest assured that our products will be updated accordingly.

Thanks.

Thanks for getting back to me.

I can’t change the theme on my live site but on my dev server - I get this error when I have PRO theme active

Warning: count(): Parameter must be an array or an object that implements Countable in /nas/content/live/ktedevelopment/wp-includes/post-template.php on line 284

If I used the 2017 theme the error is not there.

Thanks for your help
Tim

Hello Tim,

Thanks for updating in! We will be informing our developers about this Warning notices. This could be a bug or conflict in the recent release. Meanwhile, you can get rid of this notices by disabling the debug mode. You can do this by opening wp-config.php and adding

define('WP_DEBUG', false);

/* That's all, stop editing! Happy blogging. */

When you revisit the pages, you should no longer be seeing those notices.

Please let us know how it goes.

Hi Tim,

I wanted to let you know this is something WordPress has confirmed to be an issue that should be fixed on their end for PHP 7.2 compatibility. You can follow the progress here: https://core.trac.wordpress.org/ticket/42814