Getting Postgres and Movable Type to play well together

There is a bug in Movable Type: only single values (i.e scalar references) can be stored with MT::PluginData when used with a PostgreSQL database. Complex values (i.e. non-scalar references) can be stored with MySQL however, because MySQL allows binary data in its text columns (I would consider that incorrect behavior myself). PostgreSQL does not. So, to fix the problem, the binary data that the Storable perl module outputs needs to be converted to text before reaching the database. To do this, I made use of pack and unpack to trasform the data to and from hexadecimal before it gets to the database itself. I also needed to be sure to preserve any existing data already stored in the database.

The updated data method of MT::PluginData looks like this:

sub data {
    my $data = shift;
    $data->column('data', unpack ("H*", freeze(shift))) if @_;
    my $r;
    eval {
        $r = thaw($data->column('data'));
    };
    $r = thaw(pack ("H*", $data->column('data'))) if ($@);
    $r;
}

7 TrackBacks

Is there anybody out there that has got Blacklist to run with MovableType 3.11? I run MT against PostgreSQL and I get some annoying error messages: Can't call method "param" on an undefined value at lib/Blacklist/App.pm line 583. Use of uninitialized v... Read More

Is there anybody out there that has got Blacklist to run with MovableType 3.11? I run MT against PostgreSQL and I get some annoying error messages: Can't call method "param" on an undefined value at lib/Blacklist/App.pm line 583. Use of uninitialized v... Read More

There seems to be a bug in MT 3.11's MT::PluginData that breaks MT::Blacklist if you use PostgreSQL. MT's authors are using an (what I call) flaw in MySQL that makes MySQL let you store binary data in an text field.... Read More

I've been having a problem with MT-Blacklist 2.x for a while now; it stopped saving my preferences. After loads of fruitless and frustrated (and frustrating) Google and code searches, I finally found an oblique reference to the same problem with... Read More

I've been searching for a reason Movable Type didn't seem to want to play nice with PostgreSQL. (I prefer PostgreSQL to MySQL for databases where things are going to be changing somewhat often. Some will argue PostgreSQL is a real... Read More

I've been searching for a reason Movable Type didn't seem to want to play nice with PostgreSQL. (I prefer PostgreSQL to MySQL for databases where things are going to be changing somewhat often. Some will argue PostgreSQL is a real... Read More

I was wondering why the plugin I've modified to help prevent comment and trackback spam wasn't saving its cache properly.... Read More

3 Comments

Arg, I was so hopeful that this would fix the problem I was having with rebuilding my index since I had tried everything else!!

- - - - - - -
Storable binary image v35.65 more recent than I am (v2.4) at blib/lib/Storable.pm (autosplit into blib/lib/auto/Storable/thaw.al) line 355, at /usr/www/users/puppydog/mt/lib/MT/PluginData.pm line 32
- - - - - - -

But hey, thanks for posting it!

One day, I'm going to buy you a very large beer for this, I swear it.

I also owe you a large beer, a very large foamy beer with whipped cream on top or something. THANKS!

Leave a comment

Recent Entries

  • Plugin Writing 101

    So, I’m planning on writing up some entries about various aspects of plugin development. While I have a couple topics already in mind, I thought...

  • The Olympics Make Me Want To Compete Again

    Every time the Olympics come around (most the summer ones) I always start to delude myself into thinking I could complete once again in the...

  • Minimalist plugins are fun!

    Last night I whipped up one of the smallest plugins I’ve ever written. It is so small in fact that I was able to stuff...

  • Feedburner Widget on MT News

    Movable Type News A WordPress 2.5 Upgrade Guide: And of course there are lots of third-party plugins for the MT dashboard, to integrate statistics and...

  • AD&D Monster Stats for the Presidential Canditates

    Charles Stross (scifi author, D&D nerd, and former perl columnist) posted Politics as she is Played with 3d6: The recent death of Gary Gygax, who...

Close