« And then it hit me, I live here... | Main | I hate casinos... »

May 28, 2005

Strange MT Bug

I'm using Movable Type on a sqlite2 database, and I discovered that after my upgrade to the 3.1.16 on the 26th, publishing was slightly strange. Older entries weren't being included in date-based archives.

I did a bit of poking around and discovered that they "fixed" a bug with timestamp handling - and that the fix caused the timestamp format in the database to change:

[alpha@sulphurous mt]$ sqlite mt.db
SQLite version 2.8.15
Enter ".help" for instructions
sqlite> select entry_created_on from mt_entry;
...
20050520205326
20050526171309
2005-05-26 17:23:11
2005-05-26 18:07:56
2005-05-26 22:53:38

The cause was the following code which had been added to lib/MT/ObjectDriver/DBI/sqlite.pm:

sub ts2db {
    sprintf '%04d-%02d-%02d %02d:%02d:%02d', unpack 'A4A2A2A2A2A2', $_[1];
}

Not sure why they wanted to change the storage format of a timestamp, but even if it was intentional, it didn't quite work as expected. Commenting out that code, touching the timestamps on the entries in the new format, and rebuilding the site "did the right thing."

Posted by dberger at May 28, 2005 8:12 PM

Comments

Post a comment




Remember Me?


Please enter the security code you see here

(you may use HTML tags for style)