Preview Serialized WordPress Replacements With WP-CLI
Plain text replacement can damage stored PHP serialization when a string changes length. WP-CLI search-replace understands serialized data and supports a report-only dry run. Use it to decide what an approved change would touch.
Confirm the installation and the intended scope
Check the WP-CLI path, site URL and table list against an isolated staging copy. On Multisite, confirm the target subsite and intended table set. Decide which plugin tables and columns should participate and preserve the GUID column when replacing ordinary site URLs.
Run the dry run with reserved domains
For a synthetic example, use wp search-replace 'https://old.example' 'https://new.example' wp_options wp_postmeta --skip-columns=guid --dry-run --report-changed-only. Replace wp_options and wp_postmeta with the actual approved staging table names. Include one fixture with a URL in a serialized setting, then compare the reported replacement counts and tables with your expectation.
Reconcile surprising counts
A zero can indicate the wrong table, site or URL form. A large unexpected count can indicate an overbroad match. Inspect sanitized fixtures or applicable configuration in the editor. Avoid verbose logs containing actual settings or personal values. If the preview is sound, preserve it with a fresh backup and obtain the appropriate operational approval for the real change.
Expected result
The dry run identifies the intended tables and counts while leaving the database unchanged. Document exact scope and verification before a write is ever scheduled.
Related guides
- Confirm the WordPress Site Before Running WP-CLI
- How to Change the Domain of an Existing WordPress Site
Official references
Ferkesh Hosting. Last reviewed .
Thanks for your feedback!