| |

Cloudflare Plugin Hooks.php Issue with PHP 7.2

Cloudflare Plugin Hooks.php Issue with PHP 7.2

There is a bug or conflict with the Cloudflare plugin when you set your host PHP level to 7.2.

When you try to save or publish a post, or delete a spam comment, you may get a white screen with an error about the hooks.php file in the Cloudflare plugin.

See the details, where to find more info, and how to fix the problem.


See breaking news as it happens

Like, Follow, and turn on Notifications for the
BlogAid Facebook page, so you know when I stream live with breaking news.


(Details and links below the video)

Details

It’s unclear what is in PHP 7.2 that the Cloudflare hooks.php file is unhappy with.

This issue was reported as early as Jan 16, 2018 on the Cloudflare GitHub forum.

The Errors

Two errors are reported.

The first one will be easy for you to see.

When you attempt to save a post/page, or delete a comment, you will be redirected to a white screen with the following error message:

Warning: count(): Parameter must be an array or an object that implements Countable in /home/yoursite/public_html/wp-content/plugins/cloudflare/src/WordPress/Hooks.php on line 133

Warning: Cannot modify header information – headers already sent by (output started at /home/ yoursite /public_html/wp-content/plugins/cloudflare/src/WordPress/Hooks.php:133) in /home/ yoursite /public_html/wp-admin/post.php on line 198

The second error will be reported in your PHP error log, which you can see at the host via cPanel > File Manager.

[error] 1140#1140: *369161 FastCGI sent in stderr: “PHP message: PHP Warning: count(): Parameter must be an array or an object that implements Countable in /wordpress/wp-content/plugins/cloudflare/src/WordPress/Hooks.php on line 133” while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: www.com, request: “POST /wordpress/wp-admin/admin-ajax.php HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php-fpm/php-fpm.sock:”, host: “www.com”, referrer: “https://www.com/wordpress/wp-admin/post-new.php”

The Fix

The best news is, the issue is easy to fix.

Simple set your hosting PHP level back down to 7.1.

Version 7.0 will fix it too, but stay as high as you can.

Why You Need to Update to PHP 7.x

As WordPress, hosting, and plugins continue to focus on speed and security, we will be seeing more glitches like this all the way through 2019.

Older versions of PHP are no longer supported, and that is both a security and performance issue.

So, developers, and even hosts, are dropping support for older PHP versions.

That means you could update a plugin that has dropped older support, and suddenly toast your site, or lose access to it, or such.

READ: How and Why to Switch to PHP 7 for more details.