The main aim here is to search and replace the old domain name with the new one…
It seems that the simple Like %example.com% search and a replace but its lot more than that. One case as mentioned in the main idea text is the presence of serialized array in the tables. For that we can have a simple solution of
looking for serialized data first in the tables > unserialize them > making the replace in the resulting array> serialize > update
But this can be done easily only on tables… In sql files the solution will become a lot more complex as just finding serialized data will need matching. So here we can make another set of backup tables from the code and start the above process on them, say of the format [dbprefix]_wpmove_[originaltablename] but that will mean a live running site where data can be changed and it will vary from the backup table we have
So final idea sums up to
take backup> post a site down for maintainance message> look-up all occurrences of the domain in the db(except the posts table, will come to that in next point)> check if the data is serialized array>if yes follow the code section mentioned above>replace n update.
One very cool reply I got for the [wpurl] mail on wp-hackers was of Otto
function maybe_unserialize( $original ) {
if ( is_serialized( $original ) ) // don’t attempt to unserialize
{
$fixed = preg_replace_callback(
‘!(?<=^|;)s:(\d+)(?=:”(.*?)”;( ?:}|a:|s:|b:|i:|o:|N;))!s’,
‘serialize_fix_callback’,
$original );
return @unserialize( $fixed );
}
return $original;
}
this creates an array output even if we have a search and replace on the domain directly and the new domain has different characters.
try changing the count before the element data in serialized text and pass it thru this function