Documentation

Serialized Data

WordPress core and third-party plugins often serialize arrays or objects as a way of storing structured data in the WordPress database. The method used to serialize this data is PHP’s own serialize() function. Some third-party plugins also store data as JSON, using PHP’s json_encode() function.

For example, WordPress core stores all widgets as serialized data in the options table. When URLs are present in widget data, a simple find and replace on an exported SQL file would corrupt the serialization and after importing that SQL file, the widgets no longer show up.

WP Migrate properly handles this serialized data during a migration, executing find and replace on the serialized data without corrupting it. It unserializes the data, detects the data type, runs a find and replace on it (recursively for arrays), and serializes it again. It can operate on serialized strings, objects, and arrays. It also handles JSON encoded data.

Example

Given you have the following array:

$array = array( 
    'url' => 'http://mysite.com'
);

Your PHP serialized string would look like this:

a:1:{s:3:"url";s:17:"http://mysite.com";}

Let’s say you’re about to migrate from http://mysite.com to http://yoursite.com

WP Migrate DB Pro would detect this as a serialized string, unserialize it and run the find & replace. Your serialized string would then look like this:

a:1:{s:3:"url";s:19:"http://yoursite.com";}

You’ll notice that the URL has been correctly updated and the string count has been updated to 19 from 17.