If you ran a find-and-replace on your WordPress database, changed a domain or URL, and now widgets, theme options, or plugin settings are blank, you almost certainly have broken serialized data. The good news: it is fixable, and the fix is the same one that would have prevented it. Here is what went wrong and how to put it right.
Why broken serialized data happens
WordPress stores a lot of structured settings as PHP serialized strings. A serialized string records the byte length of every text value inside it, like this:
s:18:"http://old-site.com";
That s:18 means “a string of 18 characters.” When you run a plain SQL search-replace and change http://old-site.com to https://new-site.com, the text gets swapped but the length number does not. Now PHP sees s:18 in front of a 20-character string, the count no longer matches, and unserialize fails. WordPress quietly throws the value away, so your widget areas, customizer settings, and plugin options come back empty.
This is the single most common way a domain migration or staging-to-production move corrupts a site. Nothing is truly lost yet, the length counters are just out of sync with the content.
Fix broken serialized data the right way
The rule is simple: never edit serialized data by hand or with a raw SQL REPLACE(), because that is what broke it. Use a serialization-aware replacement that recalculates the length numbers for you.
Two reliable options:
- WP-CLI with
wp search-replaceis serialization-aware. It unpacks each serialized value, swaps the text, and rewrites the correct lengths before saving. - The Serialized Data Fixer repairs a specific serialized string when you have one in hand, for example a single broken
wp_optionsrow you pasted out of phpMyAdmin.
Use this numbered flow when widgets or options are broken:
- Back up the database first. Export a full SQL dump before touching anything, so you can roll back if needed.
- Find the broken value. Locate the corrupted row, often in
wp_options(theme mods, widget data) or a plugin settings row, and copy the serialized string. - Paste it into the Serialized Data Fixer. It recounts every
s:Nlength, corrects the mismatches, and gives you a valid serialized string back. - Save the repaired value back into the database row it came from.
- For a whole-site URL or domain change, run
wp search-replace 'old' 'new'instead so every serialized value across every table is recalculated in one safe pass.
The Serialized Data Fixer runs entirely in your browser. The string you paste is processed on your own device and never sent anywhere, which matters when it contains live site configuration.
How to avoid breaking it next time
Pick a serialization-aware tool from the start. Before any migration, take a database backup, then use wp search-replace (add --dry-run first to preview the count of changes) rather than editing the database directly. If you ever must export and hand-edit a dump, run the result through the Serialized Data Fixer before importing it back.
Related tools
- wp_options Autoload Analyzer - spot bloated or stale options rows that slow every page load.
- wp-config Generator - build a clean wp-config.php with correct database and salt settings.
- DB Table Prefix Generator - create a safe custom table prefix for a new install.
Back up, replace with a serialization-aware tool, and your widgets come right back.