When migrating wordpress sites, from one server/host to another… you might encounter some problems with 2 things:
- Absolute vs Relative paths for e.g. images
- Serialized data.
This is how to fix both:
Absolute paths: can be fixed by my previous post here
Serialized Data: by modifying your absolute paths for URL’s of Image paths, your serialized data is no longer valid… I have found this script to be very usefull to fix the serialized data: BangHeadOnWall
How to use fix_serialization.php:
1. Download the script on the machine that has the db you need to fix
2. Change a couple of things in the script:
- ‘db1′ to the actual database name
- username
- password
- and maybe the table/column and index column (e.g. when using multisite)
3. type ‘php fix_serialization.php’ on the command line
The only real reason why I need to run this is because migrating the site can change the tite’s url length or absolute image paths. For example ‘hard coded’ paths to images in some plugins:
1 |
'/var/www/vhosts/nicovs.be/httpdocs' -> '/var/www/nicovs/be/wwwroot' |
The length of this string changes, and therefor the serialized string in the wp_options (or any other table using serialized string with url/data paths) is not longer valid.
The script goes through all that data and corrects the math in those couple of places automagically and you’re back online!