9 September 2005

SimpleComments and SpamLookup

I’ve recently learned that Adam Kalsey’s excellent SimpleComments plugin for Movable Type is not aware of the new “junk status” flag in Movable Type 3.2 (part of the spiffy new SpamLookup suite). It’s completely understandishable since the latest SimpleComments was released prior to MT 3.2.

(Thought balloon: “Wait a sec. Didn’t I just finally get around to installing SimpleComments after upgrading to MT 3.2? D’oh!”)

Once I discovered all of my comment and trackback spam was still appearing in my freshly SimpleCommented comments, I did a bit-o-hacking and came up with what I believe to be a simple and effective plugin mod. Until the next official version of SimpleComments is released, this might do the trick for you. Keep in mind: No warranties expressed or implied, yadda yadda yadda. You know the drill …

First, you may download the patched version (MIT License applies).

WARNING: The following code snippet is now obsolete, and is (now) provided here for entertainment purposes only. Use the download link above to obtain the correct mod. Again, do not use the following code. Please read the rest of this entry all the way through … it contains a surprise PLOT TWIST! (Thank you.)

Next, here’s the behind-the-scenes tour. After stowing away a safety backup of SimpleComments.pl (located in the MT plugins directory), I added the following:


    # If we're on MT 3.2 or higher, filter out that junk!
    use constant JUNK => -1;
    if (MT->version_number >= 3.2) {
      @comments = grep { $_->junk_status() != JUNK } @comments;
      @pings    = grep { $_->junk_status() != JUNK } @pings;
    }

… and I added it immediately before this line:


    my @allComments = (@comments, @pings);

Then I tested rebuilding a really old post just to make sure all was well. (It was.) Then I rebuilt my site. Bye-bye junk, you ask? YES!

UPDATE: Cameron Bulock weighs in with a different approach! Outstanding. We’re comparing notes in the meantime. Comments most welcome.

‘NUTHER UPDATE: In the MT libraries for both Comment and TBPing I see a constant. For JUNK. Set to -1. A good sign, no? I’ve updated this entry (and the revised plugin) to reflect this constant.

THE PLOT TWIST: My hat’s off to Cameron! My technique checks the junk_status flag to determine which trackbacks pass through. That’s all well and good, but there’s a wee li’l flaw in the logic: It’s now possible to moderate trackbacks! In other words, I should be checking the “visible” flag (which is now influenced by the junk_status flag). This is what MT 3.2’s comment and trackback counters do, and it’s also what Cameron did. Thus, the technique of checking for the “visible” flag is actually the more correct one. The only icing on the cake to add is a version check and shift a few lines around. Here are the new changes, shown this time as a diff:


76a81,82
>               $terms{visible} = 1
>                       if MT->version_number >= 3.2 && $moderate;
82a89,91
>                       if MT->version_number >= 3.2 && $moderate;
>         @pings = MT::TBPing->load(\%terms, \%args);
>               $terms{visible} = 1
85d93
<         @pings = MT::TBPing->load({ blog_id => $blog_id }, \%args);

The aforementioned download link points to this improved version. If you’re not sure which one you have, your best bet is to download it again for good measure. (In the latest version, both my name and Cameron’s appear in the revision comments.)

Just to be absolutely clear, this is not a mod for the PHP port. Just the Perl version. Have fun!

Posted by joe at 12:21 AM

Comments

SimpleComments on Movable Type 3.2 from Cameron's Thought's:

I have been using the <a href="http://kalsey.com/2003/02/simplecomments/">SimpleComments</a> plugin from <a href="http://kalsey.com/blog/">Adam Kalsey</a> for a while now. When MT3 came out, there was an upda...

01:19 AM, 9 September 2005

Yet More Tweaks from eclecticism:

A few more tweaks and oddments.

03:13 AM, 17 September 2005

SimpleComments and junk status from Sideblog:

Many users have been complaining about SimpleComments' incompatibilities with 3.2, Joe guides you through hacking it to get it to work!

08:23 AM, 18 September 2005

About this Site from danandsherree.com:

danandsherree.com is run with Movable Type, a content management system. The site's design, Scrapbook, is a ground-up design of XHTML...

02:16 PM, 18 September 2005

SimpleComments und SpamLookup from einfach persoenlich Sideblog:

Das lange im Einsatz befindliche Plugin MT-SimpleComment arbeitet nicht mit den neuen Funktionen von MT 3.2 zusammen. Joe's Beitrag zeigt, wie eine kleine Modifkation diesen Fehler behebt. Auch wenn diese Funktion besser in ein MT-Plugin gefasst werden...

11:14 AM, 27 September 2005

Making SimpleComments aware of TrackBack junk status from TBOTCOTW:

Adam Kalsey's SimpleComments plugin for Movable Type was written long before MT allowed comments and trackbacks to be marked as unpublished, so in its original version it will output junked and moderated feedback. It was also written before MT had...

12:11 PM, 22 November 2005

Comments are closed for this entry.