Main

May 20, 2007

Renaming the comment script

Bots saved the name of the CGI script used for posting comments on Craftlog. So now it changes every day as part of my daily MT maintenance script. Make sure that the real script mt-comments.cgi is not executable:

Daily DB cleaning

MT 3.2 only deletes junk comments from your blog when you click on the name of your blog from the Main Menu. Presumably because they didn't want to add periodic triggers throughout the code and they thought that most people accessed their blogs every day from the Main Menu. In addition, the activity log can really slow down the DB. So I configured a cron job to clean out the DB every night:

November 04, 2006

Akismet

Akismet rocks, zero comment spam today. MT-Akismet was a snap to install. Be sure that your blog's Junk Score Threshold is 1 or less (MT default is 0), or else everything will get junked.

July 11, 2006

CGI.pm bug

I've tried this on a number of Movable Type 3.2 blogs out there, and it doesn't happen on theirs, but when you pass a badly formed query string to a CGI script, such as the query string in the Select a Design using StyleCatcher link at the bottom of the Templates page, extlib/CGI.pm croaks with the error:

Use of uninitialized value in hash element at /mt/extlib/CGI.pm line 554

That's if you're lucky and you're debugging with cgiwrapd. Otherwise you will probably just get an HTTP 500 Internal Server Error.

The offending link looks like this:

/mt/plugins/StyleCatcher/stylecatcher.cgi?;from=list_templates;blog_id=1

But I was also able to make mt.cgi die by just passing it

/mt/mt.cgi?;foo

Here's a patch which fixes the problem for me.

--- MT-3.2-en_US/extlib/CGI.pm  Wed Oct 12 08:55:56 2005
+++ mt/extlib/CGI.pm    Tue Jul 11 19:18:56 2006
@@ -546,6 +546,7 @@
     my($param,$value);
     foreach (@pairs) {
        ($param,$value) = split('=',$_,2);
+       next if not defined $param;
        next if $NO_UNDEF_PARAMS and not defined $value;
        $value = '' unless defined $value;
        $param = unescape($param);

MTEntryExcerpt

The Movable Type MTEntryExcerpt tag is annoying in that it adds an ellipsis (...) even if the entry body is short enough that it doesn't need to be truncated. Here's a patch that fixes this behavior.
--- MT-3.2-en_US/lib/MT/Template/ContextHandlers.pm     Tue Oct  4 17:01:01 2005
+++ mt/lib/MT/Template/ContextHandlers.pm       Sun Feb 12 00:14:12 2006
@@ -1045,7 +1045,11 @@
     $words = 40 unless defined $words && $words ne '';
     my $excerpt = _hdlr_entry_body($ctx, { words => $words, %$args });
     return '' unless $excerpt;
-    $excerpt . '...';
+    my $body = _hdlr_entry_body($ctx, { words => ($words + 1), %$args});
+    if ($excerpt ne $body) {
+       $excerpt .= '...';
+    }
+    $excerpt;
 }
 sub _hdlr_entry_keywords {
     my $e = $_[0]->stash('entry')