• Resolved wookieejeremy

    (@wookieejeremy)


    [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 201

    My 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());
    }
    }

    • This topic was modified 5 months, 2 weeks ago by wookieejeremy.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support amagsumov

    (@amagsumov)

    Hello @wookieejeremy,

    We have fixed the problem. All the changes will be included in the next stable release.

    Please, reinstall the plugin. ( Download link: https://github.com/CleanTalk/wordpress-antispam/releases/download/dev-version/cleantalk-spam-protect.zip )

    Here is a guide for you:

    1. Go to WordPress Administrator Panel —> Plugins.
    2. Find the plugin “Anti-Spam by CleanTalk” —> Deactivate.
    3. After the automatic page refreshing find the plugin again “Anti-Spam by CleanTalk” —> Delete. Confirm “Yes, delete these files”.
    4. Download the plugin archive from the link above.
    5. Go to Plugins —> Add New —> Upload Plugin.
    6. Choose the downloaded archive and press “Install Now”.

    Does it help?

    Fix saved three websites that shut me out of WP Admin.

    Fortunately, hosting company Hostinger has a WordPress “Overview” panel that allowed me to turn off Litespeed, which allowed me to manage Cleantalk plugin as directed.

    Now I am nervous about both Anti-Spam by CleanTalk as well as Litespeed Cache so I have them both either deleted or deactivated. Also, I wonder if the problem started with an automatic plugin update.

    Thread Starter wookieejeremy

    (@wookieejeremy)

    @philbusey My issue came from an auto update of Litespeed in the middle of the night.

    I have used both plugins for sometime without any issue. Its not uncommon for things like these to come up though. I always suggest to run updates in a staging environment to test before allowing them live, instead of auto-update for this exact reason.

    This server in particular does bi-daily backups and uptime monitoring alerts which is the only reason I leave everything auto-update (back ups are invaluable).

    In short, I wouldn’t stress too bad, just turn off auto update and reactivate them; both are necessary plugins that are important to site performance in my opinion.

    Plugin Support dimitrycleantalk

    (@dimitrycleantalk)

    Hello @philbusey,

    We are glad to know that the fixed version helped you. We also released a new version that contains these changes.

    Thanks wookieejeremy for the recommendations to not autoupdate and not uninstall necessary plugins.

    I am weighing carefully your first recommendation because websites are a part-time hobby and I have little knowledge and only so much time in the day.

    On your second recommendation, not to uninstall necessary plugins, I found out the hard way. After I uninstalled LiteSpeed Cache, on one out of three websites the page header disappeared and menu items were disarrayed across the page. The dashboard warned, Can NOT find LSCWP path for object cache initialization in /home/xxxxxxx/domains/xxx_domainname_xxx/public_html/wp-content/object-cache.php’

    The explanation went back to my mistaken uninstallation, “This error happens when you have deleted LightSpeed Cache before removing object-cache.php and advanced-cache.php files. These files created when you have installed LightSpeed Cache (LSCWP) plugin.” The webpage https://pcboy.medium.com/wordpress-fix-can-not-find-lscwp-path-for-object-cache-initialization-98857e298b2c instructed how to properly delete the orphaned Litespeed files, but I just reinstalled Litespeed and all appears well.

    This is fundamentally not an Anti-spam Cleantalk problem, but a Litespeed problem, so this sounds off-topic. But it started with a Cleantalk problem. And it illustrates overriding wordpress issues: plugin conflicts, backups, staging environments, and not to panic when things go badly.

    Plugin Support eugenecleantalk

    (@eugenecleantalk)

    @philbusey, thank you for sharing your experience.

    If you have any questions, we are always ready to help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.