Custom 404 Plugin Creating PHP Warning

Our error log kept filling up with the same error over and over again:

PHP Warning: count(): Parameter must be an array or an object that implements Countable in /home/children/public_html/wp-includes/post-template.php on line 284

By deactivating each plugin I realized the Custom 404 plugin that comes with X is what’s causing the problem. As soon as I deactivated that, the errors stopped. However, we’d still like a custom 404 page, so are you able to fix that plugin?

Hi there,

I have done some testing on my local setup and I am not able to replicate the warning message you are getting when you have the custom 404 plugin.

Kindly check if you have the latest X and Cornerstone version installed on your site as well as the version of you custom 404 plugin.

Please also note that what you are getting is just a warning message and will not affect the site’s performance.

Hi, I will jump in here to confirm the issue. I am getting this on the front-end of the 404 page:

Warning: count(): Parameter must be an array or an object that implements Countable in /home/****/public_html/wp-includes/post-template.php on line 284

On this site: https://www.core-kornati.com/.

Pro is version 2.2.5.

@Jade, have you also tested under PHP 7.2?

Thanks!

Hi @Jade,

Yes, I have all the latest X, Cornerstone, and 404 plugin versions downloaded and I’m still having the issue on our website - https://childrenscancer.org/

I’m using PHP 7.2 like Misho mentioned. It sounds like we’re not the only ones having this problem.

Any ideas? Thanks!

Hi @childrenscancer and @Misho

This issue might be related to JetPack plugin or WordPress itself according to these references:

https://core.trac.wordpress.org/ticket/42860#comment:26

it could be triggered when there is many factors exist, I couldn’t replicate this issue at my localhost which runs PHP 7.2.7-0ubuntu0.18.04.2.

Did you encounter the same issue with only Pro or X theme activated and no other plugin activated?

Thanks.

Is there a way I can just update the existing 404 page manually and not use the custom 404 plugin?

Hi @childrenscancer

First, you need to use a child theme in case you are not using one, you can follow this guide to do that:

Then, let’s assume you are using “Renew” stack, you will have to copy these files from the parent theme to the child theme directory (create any folder that doesn’t exist by default):

/x/framework/views/renew/wp-404.php
/x/framework/views/global/_content-404.php

Then modify them as you need, of course if you are using a different stack, you will have to copy its own file to its specific directory.

Thanks.

Well, it is not Jetpack. I am not using it. :slight_smile:

Hey @Misho and @childrenscancer,

I could not replicate this issue both in multisite and single install and both running PHP 7.2.0. This issue is common in PHP 7.2 but I believe there’s something specific within 7.2 setup in some sites that is causing this.

Does this error affect the functionality of the Custom 404 extension? And, for the meantime, can we hide the PHP warnings in the front-end by inserting this code in wp-config.php?

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

If you already have that, please currently ignore the warning if it’s not affecting the functionality of the plugin.

I’ll report this in our issue tracker so our development team would be made aware that this issue happens in some sites that is using PHP 7.2.

Thanks.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.