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 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 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/ croaks with the error:

Use of uninitialized value in hash element at /mt/extlib/ 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:


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


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

--- MT-3.2-en_US/extlib/  Wed Oct 12 08:55:56 2005
+++ mt/extlib/    Tue Jul 11 19:18:56 2006
@@ -546,6 +546,7 @@
     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);


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/     Tue Oct  4 17:01:01 2005
+++ mt/lib/MT/Template/       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')