MT Blacklist + Comment Queue Hack + MT Notifier

Thanks to what is now commonly known as blog "comment spam", I had shut my blog comments off last November for several months until I could take the time to figure out how I wanted to "deal" with it… at least until MovableType 3 comes out.

After recently doing some searching, and since my amount of comment traffic is not extremely high, I decided I’d love to have both Jay Allen’s wonderful MT Blacklist plugin as well as the Scriptygoddess "Coment Queue" idea (however I had to use David Raynes’ perl version because I am not running MySQL). I soon realized though that, by default, these two plugins/hacks might not necessarily "play together" too well…. but I was determined! This is an explanation of the basic steps and MT "hacks" I peformed to get MT Blacklist and the Comment Queue hack (and then later the MT Notifier plugin – see further down in the entry) (apparently) working on my blogs. Some of the comment spam still occasionally slips by MT Blacklist, but thanks to the comment queue, it will never see the light of day on this site.


PLEASE NOTE: Performing these hacks means modifying both the MT and plugin source code. If you upgrade any of these, you’ll have re-apply the hacks (if possible) to continue to have these features. I am merely posting this here in case this information can help someone else and I can offer no further help on this topic nor will I take any responsibility for what might happen if you attempt these things (especially without backups 😉 and they mess up your MT blog. Make sure to export your blog entries and backup the files before you perform any changes to them, so that you can revert if necessary!

Phew, well now that that’s out of the way…


Note again that this is using David Raynes’ perl version of the comment queue hack (non MySQL version), and also don’t forget to download and install mt-rebuild, which is used by the comment queue.

After installing MT Blacklist (version 1.6.3rc2) (follow instructions on that site), to install the comment queue I modified MT Blacklists’s "MTBlPost.pm" (found in extlib/jayallen) in the way that’s described for modifying "Comments.pm" in the Comment Queue hack (note that I applied these to the subroutine "comment_post_hdlr_266" in MTBlPost.pm, because I am using MT version > 2.66 – though this would probably work if you apply it to the "comment_post_hdlr_26" or to BOTH subroutines as well (?)):

From:

  $comment->entry_id($q->param('entry_id'));

To:

  $comment->entry_id('0');
$comment->temp_entry_id($q->param('entry_id'));

I then modified Comment.pm (found in lib/MT – note CommenT without an ‘s’) similar to how it’s described in the Comment Queue hack, though I added ‘temp_entry_id’ on to the end (I don’t think this will mess up things [e.g. the database]? Not really sure):

From:

  'id', 'blog_id', 'entry_id', 'author', 'email', 'url', 'text', 'ip'

To:

  'id', 'blog_id', 'entry_id', 'author', 'email', 'url', 'text', 'ip', 'temp_entry_id'

At this point, I was getting this error when posting a comment (though the comment apparently was entered/queued because it would show up in the entry…):

An error occurred:

Can’t use an undefined value as a SCALAR reference at …/…/lib/MT/ObjectDriver/DBM.pm line 174.

MT::App::Comments=HASH(0x8109818) Use of uninitialized value in substr at …/…/lib/MT/Serialize.pm line 49.

I am GUESSING this has something to do with the fact that you’re adding the new column (temp_entry_id) in the comments table in the database, but previous comments don’t have this column (or don’t have a value for it) – so they throw an error when they reach a certain line in DBM.pm…. So I changed a line in MT’s DBM.pm (found in lib/MT/ObjectDriver) from:

  $rec = ${ $driver->{serializer}->unserialize($rec) };

To:

  if ($rec) { $rec = ${ $driver->{serializer}->unserialize($rec) } };

BUT THEN I decided that I also wanted to use Chad Everett’s marvelous plugin "MT Notifier" to allow people to be notified when a new comment was posted on an entry…. I had previously noticed MT Notifier was described as "partially incompatible" with MT Blacklist, and instructions for getting these two to work together have already been posted. However, the comment queue hack threw another monkey wrench into the works…. This is what I ended up doing:

For MT-Notifier I applied the code hack that is supposed to be applied to MT Blacklist’s MTBlPost.pm to the Perl version comment queue’s "mt-comments-pending.cgi" instead:

This is the original code which is supposed to be applied to MTBlPost:

  require jayseae::notifier;
&jayseae::notifier::notify ( $app, $blog, $entry, $comment );

In the mt-comments-pending.cgi "allow" subroutine (sub allow) – after these two (original lines) (note: these are wrapped):

  $app->rebuild_indexes (Blog => $b) or
return "<strong>Failed to rebuild indexes: </strong>".$app->errstr . $back_to_link;
$app->rebuild_entry (Entry => $e) or
return "<strong>Failed to rebuild entry: </strong>".$app->errstr . $back_to_link;

These two lines were added:

  require jayseae::notifier;
&jayseae::notifier::notify ( $app, $b, $e, $c );

Thus, now when you "allow" a comment via the comment queue script, people will be notified by MT-Notifier! 🙂


When a new comment is submitted ("passes" MT Blacklist’s tests), it still goes into the comment queue. You administer the comments queue by accessing mt-comments-pending.cgi in your browser (as described in the pages/downloads about the comment queue hack [see above]). Et voila! Of course you should also be sure to let people know that their comments will not appear immediately by putting some explanatory text next to the comment form(s) on your MT installation.

So for now, all three of these plugins / hacks seem to be working just fine together. The downside, of course, is that I now have a very "hacked up" / unclean / impure version of MT (d’oh :-). Still, eagerly awaiting MovableType 3.