Forum

Thread tagged as: Error, Comments

Comments add-on error when trying to set to spam

I have added the latest version on the comments addon and when trying to mark a comment as spam it errors as below; PHP Fatal error: Class 'PerchComments_Akismet' not found in /home/sites/content.productions/public_html/perch/addons/apps/perch_comments/PerchComments_Comment.class.php on line 36: /home/sites/content.productions/public_html/perch/addons/apps/perch_comments/index.php

It works if the Akismet key is not set in the general settings

Martin Elliff

Martin Elliff 0 points

  • 4 years ago

I think this is missing from the /PerchComments_Comment.class

        if (!class_exists('PerchComments_Akismet')) {
            include_once('PerchComments_Akismet.class.php');
        }

I have updated my version and it works;

if ($akismet_api_key) { if (!class_exists('PerchComments_Akismet')) { include_once('PerchComments_Akismet.class.php'); }

        if ($this->commentStatus()=='SPAM' && $status=='LIVE') {
            // was marked as spam, but isn't. So tell askismet.

            $spam_data = PerchUtil::json_safe_decode($this->commentSpamData(), true);

            if (PerchUtil::count($spam_data)){
                PerchComments_Akismet::submit_ham($akismet_api_key, $spam_data['fields'], $spam_data['environment']);
            }
        }

        if ($status=='SPAM') {
            // was marked as not spam, but is spam.

            $spam_data = PerchUtil::json_safe_decode($this->commentSpamData(), true);

            if (PerchUtil::count($spam_data)){
                PerchComments_Akismet::submit_spam($akismet_api_key, $spam_data['fields'], $spam_data['environment']);
            }
        }


    }