get_option() fails to return binary result

Found the problem. And A WORD OF WARNING to people MIGRATING their WordPress Installations. Read this to understand how get_option is going to start failing when unserializing binary data from the DB.

What I did was to migrate my WordPress the hardcore way: copy all files to the web server, restore the full SQL database script.

Prior to the restore, I did a mass replace in the SQL database to change the URLs from local to web server. And that’s where the problem lies.

There were PHP serialized objects in the database. Where a string is serialized, its length is prepended. And, you can guess the clusterfuck I got myself into: since I mass-replaced the host-name, I should have modified string lengths of serialized objects everywhere I had serialized host names.

Using a default WordPress installation this would not be a problem because WordPress doesn’t use such features. But if you use Plugins or Themes and you use this method for migrating your blog, you’re asking for problems.

Luckily I have very few formerly-local URLs inside serialized objects, only two, to be precise.

I hope my 7 hours of battle with this problem will serve somebody.