Here’s what I have figured out.
ROOT CAUSE:
You have a WP Engine plugin running on your local site:
WP Engine Common
“The wpengine-common
plugin provides most of the WP Engine platform functionality. Platform features provided by this plugin can be seen in your wp-admin dashboard under the WP Engine menu icon.” (towards the bottom of that link)
PROBLEM:
Some of the functionality that that plugin offers (maybe even most or ALL functionality ) will NOT work unless it’s running on active WP Engine web hosting. That means the classes and methods being called won’t work and will error out on your local site.
ERROR BREAKDOWN:
Cause of the error is within /wp-content/mu-plugins/wpengine-common/plugin.php
Fatal error:
Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /wp-content/mu-plugins/wpengine-common/plugin.php:1348
Stack trace:
#0 /wp-content/mu-plugins/wpengine-common/plugin.php(1638): WpeCommon::is_object_cache_enabled()
ERROR TRIGGERS:
Error is triggered by both WP Rocket and bbP Style Pack, because both plugins look for WP Engine and clear WP Engine caches if the WP Engine plugin is found (specifically classes and methods for WP Engine, and they’re typically only found on actual WP Engine web hosting servers).
WP Rocket triggering the error:
#1 /wp-content/plugins/wp-rocket/inc/ThirdParty/Hostings/WPEngine.php(88): WpeCommon::purge_memcached()
#2 /wp-includes/class-wp-hook.php(312): WP_Rocket\ThirdParty\Hostings\WPEngine->clean_wpengine(‘/Volumes/G-DRIV…’)
#3 /wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters(NULL, Array)
#4 /wp-includes/plugin.php(517): WP_Hook->do_action(Array) 5 /wp-content/plugins/wp-rocket/inc/functions/files.php(860): do_action(‘after_rocket_cl…’, ‘/Volumes/G-DRIV…’, ”, ‘https://kornfel…’)
bbP Style Pack triggering the error:
#6 /wp-content/plugins/bbp-style-pack/includes/functions.php(3449): rocket_clean_domain()
#7 /wp-content/plugins/bbp-style-pack/includes/settings_topic_preview.php(17): bsp_clear_cache()
PLAIN ENGLISH:
With all that said, based on the error stack trace you posted here, it seems pretty clear what’s happening.
WP Rocket and WP Engine are just 2 of the roughly 20+ caching plugins/hosting platforms that Style Pack integrates with.
With bbP Style Pack + WP Rocket active:
1.) Style Pack says “hey WP Rocket, empty your caches”
2.) WP Rocket says “hey WP Engine, empty your caches”
3.) WP Engine says “hey self, empty your caches….oh wait…. caches aren’t available since I’m not on the WP Engine hosting server so kick out a fatal error instead”
With just Style Pack active:
1.) Style Pack says “hey WP Engine, empty your caches”
2.) WP Engine says “hey self, empty your caches….oh wait…. caches aren’t available since I’m not on the WP Engine hosting server so kick out a fatal error instead”
With just WP Rocket active:
1.) WP Rocket says “hey WP Engine, empty your caches”
2.) WP Engine says “hey self, empty your caches….oh wait…. caches aren’t available since I’m not on the WP Engine hosting server so kick out a fatal error instead”
With just the WP_CACHE global value set to true and other plugins deactivated:
1.) WP Engine says “hey self, empty your caches….oh wait…. caches aren’t available since I’m not on the WP Engine hosting server so kick out a fatal error instead”
I hope that plain English break-down is clear enough.
POSSIBLE FIX:
I think the best way to “fix” this issue is to account for whether the site is running on your local dev environment or the WP Engine web hosing server.
If local: set WP_CACHE to false and move
/wp-content/mu-plugins/wpengine-common/
to
/wp-content/mu-plugins-disabled/wpengine-common/
If live on WP Engine hosting: set WP_CACHE to true and move
/wp-content/mu-plugins-disabled/wpengine-common/
to
/wp-content/mu-plugins/wpengine-common/
Some UNTESTED code for this would look something like:
// recursive move and remove functions
// https://stackoverflow.com/questions/9835492/move-all-files-and-folders-in-a-folder-to-another
// Function to remove folders and files
function rrmdir( $dir ) {
if ( is_dir( $dir ) ) {
$files = scandir( $dir );
foreach ( $files as $file ) {
if ( $file != "." && $file != ".." ) rrmdir( $dir.DIRECTORY_SEPARATOR.$file );
}
rmdir( $dir );
}
else if ( file_exists( $dir ) ) unlink( $dir );
}
// Function to Copy folders and files
function rcopy( $src, $dst ) {
if ( file_exists ( $dst ) )
rrmdir ( $dst );
if ( is_dir ( $src ) ) {
mkdir ( $dst );
$files = scandir ( $src );
foreach ( $files as $file )
if ( $file != "." && $file != ".." ) {
rcopy( $src.DIRECTORY_SEPARATOR.$file, $dst.DIRECTORY_SEPARATOR.$file );
}
} else if ( file_exists ( $src ) ) copy( $src, $dst );
}
function bsp_wpe_mu_path() {
return WPMU_PLUGIN_DIR.DIRECTORY_SEPARATOR.'wpengine-common';
}
function bsp_wpe_mu_disabled_path() {
return WP_CONTENT_DIR.DIRECTORY_SEPARATOR.'mu-plugins-disabled'.DIRECTORY_SEPARATOR.'wpengine-common';
}
// handle environment changes
if ( strpos( ABSPATH, 'LocalSites') !== false ) {
// set WP_CACHE value to false
if ( ! defined( 'WP_CACHE' ) ) define( 'WP_CACHE', false );
else $GLOBALS['WP_CACHE'] = false;
// move wpengine-common to disabled
rcopy( bsp_wpe_mu_path(), bsp_wpe_mu_disabled_path() );
rrmdir( bsp_wpe_mu_path() );
}
else {
// set WP_CACHE value to true
if ( ! defined( 'WP_CACHE' ) ) define( 'WP_CACHE', true );
else $GLOBALS['WP_CACHE'] = true;
// move wpengine-common to mu-plugins
rcopy( bsp_wpe_mu_disabled_path(), bsp_wpe_mu_path() );
rrmdir( bsp_wpe_mu_disabled_path() );
}
There may be an easier way to accomplish this using a PHP constant or WP_ENVIRONMENT_TYPE, but as far as I can tell, it’s not 100% consistent between different environments and hosting, specifically with WP Engine.
Checking for something unique to your local environment (like specific root directory string) as I coded above may be the easiest method…at least for now.
You can add that code to your child theme (assuming you have one setup), or with the Code Snippets plugin (set to run everywhere) plugin. Keep in mind that it is untested and may need some tweaks o work 100% as expected.
IMPORTANT:
Please do us both a favor, and test out WP Rocket and Style Pack on your live WP Engine web hosting to verify that the errors disappear on actual WP Engine hosting servers. Do this before even messing with the code snippet above. You can set your site into maintenance mode (tons of plugins available for that) so that the general public doesn’t see your unfinished site. You just want to test for errors. If the errors are gone on actual WP Engine hosting, but come back when on your local dev environment, then something like the code snippet I posted above should “fix” the issue.
-
This reply was modified 1 year, 2 months ago by codejp3. Reason: fix small typos