WordPress text widget missing after site move

I moved a WordPress database over to a new home and apparently, all of my text widgets where missing. This might also happen when you try to edit your WordPress database in PHPMyAdmin (for example, you tried to manually edit a text widget in your database instead of the UI).

To fix this, go to wp-includes/functions.php and change this or comment it out:

function maybe_unserialize( $original ) {
	if ( is_serialized( $original ) ) // don't attempt to unserialize data that wasn't serialized going in
		return @unserialize( $original );
	return $original;
}

(should be around ling 252)

to this:

function maybe_unserialize( $original ) {
    if ( is_serialized( $original ) ) {
        $fixed = preg_replace_callback(
            '!(?<=^|;)s:(\d+)(?=:"(.*?)";(?:}|a:|s:|b:|i:|o:|N;))!s',
            'serialize_fix_callback',
            $original );
        return @unserialize( $fixed );
    }
    return $original;
}
function serialize_fix_callback($match) { return 's:' . strlen($match[2]); } 

This code should fix serialized data.

 

Author Bio

Thank you for your interest in my blog! On this miniblog, I write mostly short (technical) blog posts that might interest other people. Read more about me or feel free to contact me.

 

One thought on “WordPress text widget missing after site move

Leave a Reply

Your e-mail address will not be published. Required fields are marked *