Conflict with Lightspeed Cache
-
[03-Oct-2024 10:28:03 UTC] PHP Fatal error: Uncaught TypeError: json_decode(): Argument #1 ($json) must be of type string, array given in *****/wp-content/plugins/cleantalk-spam-protect/lib/Cleantalk/ApbctWP/AdjustToEnvironmentModule/AdjustToEnv/AdjustToEnvLiteSpeedCache.php:201
Stack trace: 0 *****/wp-content/plugins/cleantalk-spam-protect/lib/Cleantalk/ApbctWP/AdjustToEnvironmentModule/AdjustToEnv/AdjustToEnvLiteSpeedCache.php(201): json_decode() 1 *****/wp-content/plugins/cleantalk-spam-protect/lib/Cleantalk/ApbctWP/AdjustToEnvironmentModule/AdjustToEnv/AdjustToEnvLiteSpeedCache.php(70): Cleantalk\ApbctWP\AdjustToEnvironmentModule\AdjustToEnv\AdjustToEnvLiteSpeedCache->setLiteSpeedCacheJsExcludesState() 2 *****/wp-content/plugins/cleantalk-spam-protect/lib/Cleantalk/ApbctWP/AdjustToEnvironmentModule/AdjustToEnv/AdjustToEnvAbstract.php(25): Cleantalk\ApbctWP\AdjustToEnvironmentModule\AdjustToEnv\AdjustToEnvLiteSpeedCache->doAdjust() 3 *****/wp-content/plugins/cleantalk-spam-protect/lib/Cleantalk/ApbctWP/AdjustToEnvironmentModule/AdjustToEnvironmentHandler.php(47): Cleantalk\ApbctWP\AdjustToEnvironmentModule\AdjustToEnv\AdjustToEnvAbstract->run() 4 *****/wp-content/plugins/cleantalk-spam-protect/inc/cleantalk-updater.php(1290): Cleantalk\ApbctWP\AdjustToEnvironmentModule\AdjustToEnvironmentHandler->handle() 5 *****/wp-content/plugins/cleantalk-spam-protect/inc/cleantalk-updater.php(72): apbct_update_to_6_42_0() 6 *****/wp-content/plugins/cleantalk-spam-protect/cleantalk.php(3302): apbct_run_update_actions() 7 *****/wp-content/plugins/cleantalk-spam-protect/cleantalk.php(239): apbct_update_actions() 8 *****/wp-admin/includes/plugin.php(2387): include_once('…') 9 *****/wp-admin/includes/plugin.php(673): plugin_sandbox_scrape() 10 *****/wp-admin/plugins.php(60): activate_plugin() 11 {main}
thrown in *****/wp-content/plugins/cleantalk-spam-protect/lib/Cleantalk/ApbctWP/AdjustToEnvironmentModule/AdjustToEnv/AdjustToEnvLiteSpeedCache.php on line 201My Fix
private function setLiteSpeedCacheJsExcludesState($state)
{
$state = (bool)$state;
if (!(
apbct_is_plugin_active('litespeed-cache/litespeed-cache.php') &&
get_option('litespeed.conf.optm-js_exc')
)) {
return;
}
$current_js_exc = get_option('litespeed.conf.optm-js_exc');
// Check if the current JS exclusion list is already an array
if (!is_array($current_js_exc)) {
$current_js_exc_array = json_decode($current_js_exc, true); // Decode as associative array
} else {
$current_js_exc_array = $current_js_exc;
}
if (!isset($this->info[static::class]) || !key_exists('original_config_js_exc', $this->info[static::class]) ) {
$this->info[static::class]['original_config_js_exc'] = $current_js_exc;
}
try {
if ($state === false) {
// Add 'apbct-public-bundle.min.js' to the exclusion list
$current_js_exc_array[] = 'apbct-public-bundle.min.js';
} else {
// Remove 'apbct-public-bundle.min.js' from the exclusion list
$current_js_exc_array = array_filter($current_js_exc_array, function ($value) {
return $value !== 'apbct-public-bundle.min.js';
});
}
// Encode back to JSON and update the option if it was originally a JSON string
if (!is_array($current_js_exc)) {
update_option('litespeed.conf.optm-js_exc', json_encode($current_js_exc_array));
} else {
update_option('litespeed.conf.optm-js_exc', $current_js_exc_array);
}
if (class_exists('\LiteSpeed\Purge')) {
Purge::purge_all();
}
} catch (\Exception $e) {
error_log('Antispam by CleanTalk error: ' . __METHOD__ . ' ' . $e->getMessage());
}
}
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- You must be logged in to reply to this topic.