When updating your site to WordPress 7.1, you may encounter a "There has been a critical error on this website" message if you have the WP Rocket plugin active.
This is caused by a type mismatch in WP Rocket's Cloudflare CDN module (inc/ThirdParty/Plugins/CDN/Cloudflare.php), where WordPress 7.1 passes non-string filter keys to substr().
If you'd prefer not to edit core plugin files, you can temporarily disable WP Rocket to regain access to your site while waiting for an official update.
/container/application/public/wp-content/plugins/wp-rocket folder to wp-rocket-disabled.This method keeps WP Rocket active and caching operational by adding a string type-cast to the affected line.
Access the site files via SSH/SFTP
Navigate to the following path: /container/application/public/wp-content/plugins/wp-rocket/inc/ThirdParty/Plugins/CDN/Cloudflare.php
Open Cloudflare.php and locate line 562:
if ( substr( $key, - strlen( $method ) ) !== $method ) {
Replace line 562 with the following code (adding (string) before $key):
if ( substr( (string) $key, - strlen( $method ) ) !== $method ) {
Save the file and refresh your site.
Note that this is a community patch and WP Rocket may not work as expected. If this is the case we'd recommend following Method 1 to disable the plugin.
This issue is tracked in WP Rocket's repository at https://github.com/wp-media/wp-rocket/issues/8596
Once WP Rocket releases an official plugin update containing this fix, you can safely update the plugin through your WordPress Dashboard, which will overwrite any temporary manual changes made above.
Need further assistance? Contact our support team for help applying this patch to your account.
As an alternative to WP Rocket, we'd recommend trying the WP Super Cache caching plugin: https://wordpress.org/plugins/wp-super-cache/