<- All articles WordPress migration

Why search-replace is serialization-safe

Published on June 14, 2026

How to change a WordPress site's URL without corrupting serialized data.

Conceptmigrate-toolkit.bitechlab.com

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

  1. It deserializes the value if it is serialized.
  2. It recursively traverses arrays, objects, and nested strings.
  3. It replaces the old string with the new one.
  4. 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