How One WordPress Migration Plugin Has Saved Us Thousands of Dollars

If migrate WordPress websites you’ve likely run into strange behavior. You’ve also likely spent hours troubleshooting and manually rebuilding things.

And all those hours over a year can add up to thousands of dollars worth of time.

Earlier this month, my team ran into a strange issue during a WordPress migration from our dev environment to a customer’s production environment.

For some reason the custom post type we created just disappeared.

There were no errors thrown. There were no warning messages. There was nothing to indicate we had a misconfigured something-or-another. No blue-screens/white-screens/black-screens of death.

The feature built on the custom-post-type was just…gone. So we did one more sanity check, and everything still worked fine in our dev environment.

The Bug Hunt

We investigated a number of possible causes that allowed us to rule-out an issue with the hosting provider. We deactivated plugins. We re-imported the database. We toggled debug mode on/off. We dumped arrays. We hoped. We despaired.

And then, an internet voice whispered: “Serialized data.”

Did You Know?

Data serialization is a way of storing structured information in a database using the php method serialize(). If you’ve ever looked inside a data base you’ve probably seen it but not realized what it was.

Here’s a quick example of data serialization from deliciousbrains.com:

$array = array(
'url' => 'https://vsellis.com'
);

PHP string using serialize():

a:1:{s:3:"url";s:18:"https://vsellis.com";}

What’s important is the s:{variable} in the example above. That value tells you the length of the string.

A HA!

Take the above example and then consider what would happen if you changed the URL in the example but did NOT change the value of s:{variable} to correspond with the URL value.

Whoops!

You think that would blow something up? You think that might result in a little hitch in your giddyup? You think that might cause our custom functionality to DISAPPEAR?

If you said “Yes” you’d be right. It would, and it did.

Your Problem Solved

Enter stage left, today’s migration hero! WP_MIGRATE_DB (free version) from the gents over at deliciousbrains.com. They have put together such a great migration tool that it has become a part of our standard suite of tools we use and resell as affiliates (only the good stuff you know).

In short, this plugin take whatever string(s) you want to search and replace for, unserializes() the data and then re-serializes() the new result back into the database. Like so:

s:5:"hello"

becomes…

s:11:"hello world"

Brilliant, right?

But Wait! There’s More!

It’s not just custom post-types this affects. A lot of WordPress data is serialized so anytime you move a database there is the risk issues.

Let’s say you have widgets that disappear when moving from one environment to another. Ever bumped into that one?

Stop scratching your head and manually rebuilding them.  WordPress stores widgets as serialized data too and WP_MIGRATE_DB will handle that as well.

On an annual basis, the amount of time saved by understanding the data-serialization issue and using WP_MIGRATE_DB to more quickly move databases, especially big ones, adds up fast.

Image courtesy Peter Alfred Hess via Flickr Creative Commons.

Leave a Comment