January 15, 2006

Movable Type Upgrade

I just upgraded patrick.com’s Movable Type to 3.2. I had a problem that others have had as well, but that I haven’t seen a solution to, so I figured I’d document it here.

During the web-based upgrade process, I kept getting this error:

Error during upgrade: Can’t call method “basename_limit” on an undefined value at lib/MT/Util.pm line 719.

The line in question does this:

    my $limit = $blog->basename_limit || 30; # FIXME

The problem is that if you have entries in your database for a blog that has been deleted (theoretically impossible, but apparently can happen in practice), $blog will be undefined and the upgrade will explode. Changing the line to use the ternary operator:

     my $limit = ($blog ? $blog->basename_limit : 30);

doesn’t get you much further, since the whole subroutine assumes that $blog is valid.

In my case, I went into the MySQL database directly and deleted everything in mt_entry tables where entry_blog_id wasn’t 2 (the blog_id of patrick.com):

delete from mt_entry where entry_blog_id != 2

The upgrade made it a little further, then blew up again while upgrading permissions. I took a look at the mt_permissions table and, sure enough, it had references to a non-existant blog. I ran my cleanup query again on that table:

delete from mt_permission where permission_blog_id != 2

And the upgrade finished successfully. As always, take care when futzing around directly with your MT database and if you use this recipe to try and solve your problem, be sure to change the blog_id to match whatever your blog_id is (or blog_ids are)!

Hope this helps someone else having the same problem.

Posted by pmk at January 15, 2006 1:05 AM | TrackBack
Comments

Thank you thank you thank you. Your fix just worked perfectly and my upgrade was successful!

Posted by: Carrie at April 25, 2006 11:39 PM
Post a comment









Remember personal info?