Spam Karma Hack: Spam Leftovers
Read the update, this has been put in the latest version of Spam Karma!
One of the changes in WordPress 1.5 is that comment spam isn’t actually deleted when encountered by the built-in anti-spam measures, it is silently stored in your database and marked as spam. It won’t ever show up on your blog or in the interface, but it is there if you need it.
Spam Karma is the best 3rd party anti-spam tool for WordPress. When Spam Karma encounters obvious spam, it deletes it. Why not keep that spam in the database, marked as spam, as WordPress 1.5′s built-in anti-spam measures do? The benefits of this are twofold. First, if a legitimate comment gets caught by Spam Karma, you can easily restore it, as it is still in the database. Second, future versions of Spam Karma or WordPress may make spam decisions based on the known spam you have stored in your database, so eventually this could increase your blog’s ability to recognize spam.
The first change you need to do is in Spam Karma. In the Spam Karma plugin file (/wp-content/plugins/spam-karma.php) delete this line (it is line 2173 in SK 1.19 alpha 1):
$wpdb->query("DELETE FROM {$wpdb->comments} WHERE comment_ID = {$comment_ID} LIMIT 1;"); // kill the nasty bugger...
In its place put this:
$wpdb->query("UPDATE {$wpdb->comments} SET comment_approved = 'spam' WHERE comment_ID = {$comment_ID} LIMIT 1;"); // save as spam
Save the file and upload it to your server.
Now, for restoration of false positives, you need a way to access comments marked as “spam” from within the WordPress interface. This capability comes via an excellent plugin from ColdForged called the Paged Comment Editing Plugin. Drop this little beauty into your plugins folder and activate it. Now, by going to Manage -> Comments in the WordPress interface, you will be able to display comments marked as spam by clicking “Only Spam.” To restore a legitimate comment that was erroneously marked as spam, click “Edit Comment” and change its status to “Approved.”
Mmm… spam leftovers.
Update: I put this hack, as well as several fixes for full WordPress 1.5 compatibility into a new version of Spam Karma, and it is now available. Go get it! Note that the Cold Forged plugin is still of use for “undeleting” comments.
