<- All articles
WordPress migration
Why search-replace is serialization-safe
How to change a WordPress site's URL without corrupting serialized data.
The problem
WordPress stores many options as serialized PHP data. This format encodes the length of each string. If you replace a URL with another of a different length using a simple SQL search/replace, the declared length no longer matches, and WordPress can't read the data.
A concrete example
A serialized siteurl option. The s:25 indicates a string of 25 characters.
a:1:{s:7:"siteurl";s:25:"https://ancien-domaine.com";}
Naive replacement (incorrect length, corrupted data):
a:1:{s:7:"siteurl";s:25:"https://nouveau-domaine.com";}
Serialization-safe (recalculated length):
a:1:{s:7:"siteurl";s:26:"https://nouveau-domaine.com";}
How the tool works
- It deserializes the value if it is serialized.
- It recursively traverses arrays, objects, and nested strings.
- It replaces the old string with the new one.
- It re-serializes: PHP then automatically recalculates the lengths.
Result: you can change domains with different lengths without ever breaking a widget, menu, or Elementor setting.
Migrate a WordPress site hassle-free
WP Migrate Toolkit moves files + database over FTP, without SSH.
Download the CLI Download the plugin