I just launched a project, and despite using a heavily tried-and-tested script for dealing with serialized data in migrating, we ended up with some custom field values that weren’t being output (in admin or on the front-end) because the serialized values had become corrupted. I think it must have been something strange to do with characters pasted in from Word, maybe in conjunction with the recent WP core upgrade to handling utf8mb4
data. I’m not sure.
In any case, I found a PHP script that repairs serialized data, and turned it into a plugin: Repair Meta.
It’s pretty basic. This is what it does:
- It adds a Repair meta option to the row actions for posts (including custom post types) and pages.
- Clicking this will search for serialized arrays in the post’s meta, and repair them if possible.
- The replaced value(s) are stored in a file in the uploads folder, just in case. Note that this file’s contents only apply to the last operation – it’s overwritten the next time you click Repair meta.
It should go without saying, back up all your data before using this plugin! Hopefully it’ll be useful.