3

I have recently moved a multisite network to a new domain. There is only 1 site in the network currently (I'm in the process of building the sites for the network and I am pushing this one to a staging server for testing).

To move the site I did the following:

  • Transferred ALL files
  • Exported the full database from database A and imported into database B on staging
  • Ran a series of find & replace queries on all tables to replace the old domain with the new domain
  • Updated my wp-config.php file on the staging server with the correct DB info and the updated URL

At this stage nearly everything works perfectly, everything except theme customisations. I realise this is stored as a serialized array, and I've updated the length of each of the fields accordingly. See below for the stored value:

a:19:{i:0;b:0;s:8:"tcx_logo";s:72:"http://stange.********.com/wp-content/uploads/2014/11/***-***-bottle.png";s:13:"tcx_address_1";s:12:"***** Avenue";s:13:"tcx_address_2";s:0:"";s:12:"tcx_citytown";s:7:"*******";s:10:"tcx_county";s:6:"******";s:12:"tcx_postcode";s:8:"**** ***";s:11:"tcx_country";s:0:"";s:7:"tcx_lat";d:**.**********0000076470314525067806243896484375;s:7:"tcx_lng";d:-*.**********00000065853100750246085226535797119140625;s:12:"tcx_facebook";s:12:"************";s:11:"tcx_twitter";s:12:"************";s:18:"nav_menu_locations";a:2:{s:9:"main-menu";i:2;s:6:"footer";i:3;}s:16:"tcx_openingtimes";s:0:"";s:13:"tcx_foodtimes";s:225:"<dl class="dl-horizontal">
    <dt>Monday to Thursday:</dt>
    <dd>12noon - 2:30pm & 5:30pm - 9:00pm</dd>

    <dt>Friday & Saturday:</dt>
    <dd>12noon - 2:30pm & 5:30pm - 9:00pm</dd>

    <dt>Sunday:</dt>
    <dd>12noon - 8:00pm</dd>
</dl>";s:13:"tcx_telephone";s:13:"**** *** 5535";s:9:"tcx_email";s:27:"info@****************.co.uk";s:14:"tcx_bookatable";s:17:"Bookatable Widget";s:10:"tcx_seekom";s:13:"Seekom Widget";}

Sensitive information has been ******'d.

Whenever I visit the customisation area of the theme I see the fields, but don't see any of the values. None of the stored values are shown on the frontend either, which leads me to believe it is a problem with this field in the database.

Any ideas?

Mike
  • 8,767
  • 8
  • 49
  • 103
  • 1
    Incidentally, if you're not using https://github.com/interconnectit/Search-Replace-DB for doing the site URL replacement, I recommend it. It will search into serialised data and replace it correctly, and it's used by many people for this precise purpose. Also: is the stored value in your question the "before" or "after" version? Could you provide us with both? – Matt Gibson Dec 22 '14 at 17:34
  • (Also, when ***** the data, it would help if you'd use something numeric, like "0", for the numeric values ("d:...")—that way you won't break the serialisation...) – Matt Gibson Dec 22 '14 at 17:46

1 Answers1

0

Your problem seems to be with this section:

s:225:"<dl class="dl-horizontal">
    <dt>Monday to Thursday:</dt>
    <dd>12noon - 2:30pm & 5:30pm - 9:00pm</dd>

    <dt>Friday & Saturday:</dt>
    <dd>12noon - 2:30pm & 5:30pm - 9:00pm</dd>

    <dt>Sunday:</dt>
    <dd>12noon - 8:00pm</dd>
</dl>"

...where I think you've counted the characters wrong. Certainly if I cut and paste your version—and replace the asterisks that you've put in numeric fields—I need to set the length to be 243, not 224, in order to properly deserialise. However, given that copying and pasting to and from Stack Overflow is probably confusing things, it's hard to be sure. There are almost certainly some issues in the whitespace that will make this hard to diagnose.

If it is a problem with the manual update of your serialisations, you should see errors, at least in the server error log, which will help you pinpoint the problem, e.g. "PHP Notice: unserialize(): Error at offset X of Y bytes in /path/to/file.php", which might give you some clues.

I recommend that instead of updating lengths manually, you use a script designed specifically for this purpose, that will deserialise the values in your database, do the replacement, and then reserialise them. I use Search-Replace-DB for exactly this purpose when pushing WordPress databases to my staging site.

Matt Gibson
  • 37,886
  • 9
  • 99
  • 128
  • Weird, I get 254 for that string length, not 225. Seems like a whitespace issue, and possibly one of many. I have re-imported the DB and run the search and replace script, working great now. Thanks – Mike Dec 23 '14 at 09:57