WordPress Search and Replace Tool
When you’re migrating WordPress (or any other platform using serialized PHP strings in the database) between domains, you must use a safe search and replace method that preserves the integrity of the serialized string lengths. A simple of a dump file for http://localhost to, for example, http://yournewdomain.com is problematic because the length of the string changes but the indexes for the serialized strings does not. Consequently settings are lost and widgets and settings disappear!
This script can now also handle multiply nested serializations, which can happen in transient values in WP at times, and it can also handle multi-byte Unicode changes safely. This is important now that internationalised domain names are allowed.
Best of all it’s not only for WordPress!
It’s worth mentioning that the code will work for any platform that stores PHP serialized arrays in a MySQL database. You can easily use this script on Drupal, Joomla and many other systems where you need to change items across a database without messing up your stored arrays.
Installation & use
To use the script, you should install it in the root folder of your WordPress install (if you wish it to automatically pick up your wp-config) or anywhere else you fancy, but you won’t get the automatic config. You should also, to protect yourself from automated scanners looking for this script, rename it first. eg, you could name it as rrrrreplace.php – you’d then visit a url like http://example.com/rrrrreplace.php and follow the on-screen instructions from there.
What you absolutely, 100% certainly MUST do is to delete the script once you’ve finished. If somebody chances on it they can do anything to your database – and that wouldn’t be nice, would it?
This code is supplied with no warranty or support implied. You use it entirely at your own risk. Currently it is supplied under the WTFPL but this will change to the GPL eventually. And when you’ve finished using the script, PLEASE delete it as it can pose a serious security risk to your site.This script is provided by InterconnectIT.