Serialized PHP repair

Paste a broken option value. It recounts every string and rewrites the length prefixes, and can do the domain replacement at the same time.

Runs entirely in your browser. Nothing you paste is uploaded, which matters here because option values routinely contain API keys.

Why a find-and-replace breaks WordPress

Plugin and theme settings live in wp_options as PHP-serialized arrays, and a serialized string carries its own byte length:

s:19:"http://old-site.com"

Change the domain with a SQL find-and-replace and the text changes while the number does not. PHP then refuses to unserialize the whole option.

The symptom is not an error message. It is a widget that silently forgets its settings, a slider with no slides, or a customiser that reverts to defaults - often noticed days later, with nothing in the logs pointing at the migration that caused it.

Bytes, not characters

PHP counts bytes. An accented character is two, an emoji is four. A "fixed" blob that counted characters will fail somewhere else instead, which is worse than not fixing it, because the next person assumes it has already been checked.

This tool counts bytes throughout.

Do the replacement properly instead

This page repairs damage that has already happened. To avoid it, use something that understands serialization rather than a raw SQL query:

  • WP-CLI: wp search-replace 'http://old' 'https://new' --all-tables unserializes, replaces and re-serializes correctly. Run it with --dry-run first.
  • Better Search Replace, if you would rather work in wp-admin.

A plain UPDATE wp_options SET option_value = REPLACE(...) is the thing that causes this, every time.

What it cannot do

If the value was truncated rather than mis-counted - a column too small, or a copy that grabbed half of it - the data is gone and no arithmetic recovers it. The tool says it could not parse it rather than guessing.