Around 3am this morning, I got to wondering what it'd take to write a command-line script that, given a post id number, would cause MT to regenerate it. The reason I need this (at least as a stepping stone) is that in my quest to remove blog pop-ups I neglected to notice that MT doesn't rebuild the entry page upon receiving a TrackBack ping--only when a comment is posted. This was pointed out by several folks in the comments. Someone even pointed to a patch that fixes this.
Instead, I wanted a way to do this without relying on a patch that may or not still work after the next MT upgrade. So I did a bit of poking around and read some of the MT perl module documentation. What I found made me very happy.
- MT is very well documented, from a programmer's point of view
- MT is very well designed, from a programmer's point of view
- Doing simple things in MT really is simple
With that in mind, I created a few test scripts before settling upon what I wanted. I devised a script called rebuild_recent.pl. Given a number (N) on the command-line, it rebuilds the N most recent entries. Have a look. It's really quite simple. Just drop it in your MT directory and it'll work.
Now I mentioned that this is a stepping stone. Since I recently moved from Berkeley DB to MySQL for the back-end, I'm going to rig up a cron job that scans for recent TrackBack pings and rebuilds affected entries. If I run it every 2-10 minutes, that should be sufficient.
Kudos to Ben and Mena for a great product that's also hacker friendly.
Posted by jzawodn at June 09, 2003 11:47 AM