Migrating WordPress site with Zerif-Lite theme

I recently had to help my wife with her WordPress site, and I learned quite a bit about themes, and how tricky migrating a WordPress site can be.

After setting up a new WordPress site on my wife’s laptop, we decided to use the Zerif-Lite theme on ThemeIsle. It’s a one page theme that looks clean, modern and minimalist.

Customizing the theme was easy, which is what you’d expect from a WordPress theme. My wife quickly added all her content and the homepage was ready to go live. Next step was migrating the site from her laptop onto our hosting company’s server.

I have done migrations in the past, which went relatively smooth, but this time was different. I followed the usual process which is to upload the website files via ftp, exporting and importing the database with a script (remembering to find and replace the localhost URL with the new URL) and finally updating wp-config.php with the database settings.

When I first visited the homepage I got a blank white page, others refer to it as the white screen of death. I then enabled debugging in the wp-config.php file. This didn’t do much.

I noticed not all the files got uploaded, something I should have checked first. I uploaded the missing files, but still had the same problem.

I was just about ready to contact our hosting company, when I noticed an error file was generated in wp-content. I downloaded the file and saw the following:

Parse error: syntax error, unexpected T_FUNCTION in /public_html/wp-content/themes/zerif-lite/inc/jetpack.php on line 1

I’m still not sure why I got this error, but I found other people with the same problem, the suggested fix was to re-install the theme. I did this, and it worked, the site now loaded the theme correctly. The only problem now was that my wife’s content was gone, the theme’s default content was back.

I decided to drop all the database tables and migrate the tables from localhost to live again. Still the theme’s default content was showing, this was really strange. I decided to dig into the database, to try and find where the theme’s content was being stored.

It turns out that the content is saved in the wp_options table. One of the option entries is theme_mods_zerif-lite. The content was in this strange format:

a:54:{i:0;b:0;s:19:"zerif_bigtitle_show";s:0:"";s:20:"zerif_bigtitle_title";s:22:"Organizing In Progress";...

I found out that this is a serialized string. Some developers like to store objects in a single string, and the way to do that is to serialize the object. If you think about it, it’s easier to maintain because you don’t have to look for objects in many places. The issue that other developers might have with this, is it’s not easy to query the data. Storing data in this way, is not really how it should be done in a relational database.

I did some more research and found out that I messed up the serialized strings when I did the find and replace while migrating the database. The problem was the string lengths were incorrect, so php could not deserialize the string. That’s why the theme was reverting back to the default content, it could not successfully load up my wife’s custom content.

I then had a detailed look at the serialized strings, and updated the string lengths where I had replaced the localhost URL with the live URL. For example:

s:94:"http://localhost/juanita/wp-content/uploads/2015/06/table-white-home-interior-original-doc.jpg";

became

s:107:"http://www.organizinginprogress.co.za/wp-content/uploads/2015/06/table-white-home-interior-original-doc.jpg";

I used two online resources which made things easier.

http://unserialize.onlinephpfunctions.com/ – Test if a serialized string can be deserialized.

https://www.functions-online.com/serialize.html – Used to serialize a string.

It was not only the find and replace that was causing trouble, I had to check strings where the carriage return and newline characters (\r\n) were used.

The theme now showed the correct content, but there were still some content missing in places where widgets were used. I found another entry in the wp_options table that had to be fixed, it was called widget_ctup-ads-widget.

Finally the homepage was the same as it was on localhost.

As a side note, I read an interesting post that touched on some things that users should be aware of when selecting a WordPress theme, especially themes like Zerif-Lite.

Read it here.

How to start a blog

I use google a lot! In fact, I wouldn’t be able to do my job if it wasn’t for google.

That’s the reason I started blogging, to give back, to help others.

If you want to start blogging, wordpress is for you. You can have your very own blog in minutes.

To get started with wordpress head over to the wordpress.com website and follow the steps to get your own blog.

There are other options, but I recommed wordpress because it’s my favourite blogging platform, and:

  • it’s easy to use.
  • it’s been around for quite a while.
  • there are a lot of resources on the internet if you get stuck.
  • it’s free!