Testing for WordPress Upgrade Incompatibilities

So you’ve taken the plunge and started a website powered by WordPress. Everything is great. You’re posting news to your blog, adding static content pages and taking the internet by storm. Then you start seeing notices in your dashboard that you need to update WordPress itself or perhaps one of your plugins or the theme you are using. How quickly should you jump on the update bus? What if something goes wrong with one or more of the updates and your site is borked?

The answer to all of these questions isn’t definitive but there are some general rules and actions you can take to help ensure that keeping up-to-date doesn’t end up bringing your whole website down.

What Causes a WordPress Website to Fail?

There are dozens of ways your WordPress website could potentially fail but I will only cover three in this post. These mostly occur when you are upgrading WordPress, one of your plugins or your theme:

  • PHP version incompatibility
  • plugin and/or theme incompatibility
  • plugin and/or theme bug

PHP Version Incompatibility

If a WordPress core, plugin or theme update includes PHP functions incompatible with the version of PHP installed at your web hosting provider you will end up with a broken website. This usually manifests itself as the “white screen of death” (you visit a URL and all you get is a blank page) or a call to an undefined PHP function (you get a “PHP Fatal error: Call to undefined function…” message at one or more URLs for your website).

PHP version incompatibility can be further sub-divided into two scenarios:

  1. compatibility with your version of PHP is removed with the update
  2. new PHP functionality included in a newer version of PHP is introduced with no fallback mechanism for older PHP versions

The solution for this issue is to utilize a newer PHP version (usually available with most quality web hosting providers) or to roll-back the update(s).

Plugin and/or Theme Incompatibility

In some cases, an update for a plugin or theme will introduce an incompatibility with either WordPress core or another plugin or your installed theme. In this scenario your only choices are to contact the plugin or theme developer to report the issue and hope that they can implement a fix or, again, roll-back the update(s).

Plugin and/or Theme Bug

On occasion, an updated plugin or theme will include a bug. A bug can be anything from something simple (e.g., missing text and/or content), to something serious (e.g., incorrect content) to something fatal (e.g., call to an undefined PHP function). These should be reported to the plugin or theme author so that a fix can be implemented. Until that happens, your only choice to retain a functional website (assuming the bug is a critical one) is to roll-back the update(s).

Avoiding Bugs and Incompatibilities During Updates

If most issues with WordPress websites occur after updating one of  WordPress core, a plugin or a theme what is the best strategy to avoid them? Have a clone of your website to test the updates on before rolling them out to your live website!

Using a Virtual Machine

Creating a clone website isn’t difficult if you leverage one of the many available “virtual machine” applications. There are several including VMWareParallels and several others. I personally utilize VirtualBox which is open-source software with a GPL license and is currently developed by Oracle Corporation. VirtualBox can be installed on Windows, Mac OS X and Linux among other operating systems. You can install any “guest OS” that will run on X86 hardware.

Installing a LAMP Stack

Once you have virtual machine software installed you will need to install the appropriate “guest OS” and software stack to replicate your web hosting provider’s software stack. In most cases, this will be what is called a LAMP stack (Linux, Apache, mySQL, PHP). The only likely exception to this is that your web hosting provider may use a different web server (such as Nginx) in place of Apache.

You could install all of the above software individually. However, unless you are well-versed in Linux system administration it is much easier to install a pre-packaged LAMP software stack from one of two “virtual appliance” providers:

Personally, I use TurnKey Linux.

To make life easier on yourself, you should just select the WordPress virtual appliance. That way you’ll have WordPress pre-installed and ready to go (with a possible upgrade to the newest version of WordPress). This appliance includes Linux (Debian distro), Apache, mySQL, PHP, PHPMyAdmin, Postfix as well as Webmin. If your web hosting provider uses the standard LAMP stack, this should suffice.

What if your web hosting provider uses something other than the standard LAMP stack? In that case, you’ll probably need to go with Bitnami as they provide a Nginx stack (Linux, Nginx, mySQL, PHP). If your web hosting provider has a more “unique” software stack then you’ll likely be on your own setting up a duplicate environment on your virtual machine. As long as the components are open-source you should be able to accomplish this, although you may need to delve into system administration tasks along the way.

Duplicating Your Web Hosting Providers Software Environment: How Exact Do You Need To Be?

Hopefully, at this point you will be wondering if you need to install the exact versions of each component of your web hosting providers software stack. The answer to this depends on how thorough you want to be and how much time you want to spend.

Duplicating the software components of your web hosts environment without necessarily duplicating the exact versions of each software component will go a long way in testing for problems when applying WordPress updates. Such an environment will likely catch both incompatibilities and bugs in updates to plugins or themes.

However, you will likely miss issues with PHP versions if you do not replicate your web host’s environment down to the exact versions in use (don’t forget that both Apache and PHP can be configured with a multitude of options as well). Doing this is a substantial amount of extra work and may or may not be worth any future returns in catching PHP issues before they affect your live website. I personally don’t go to this level of duplication. However, if you feel the need to create an exact duplicate, knock yourself out as it can’t hurt!

Cloning Your WordPress Site

Once you have your WordPress appliance up and running on your virtual machine, you will need to “clone” your WordPress website. There are several ways to do this with each creating either an exact clone of your site or a “functional” duplicate:

  • functional duplicate—WordPress import/export functionality
  • exact clone—mySQL import/export functionality and download of WordPress files

Again, I go the non-perfectionist route and simply utilize the WordPress import/export functionality via the WordPress Importer plugin. The downside to this route is that you will need to install WordPress to your LAMP virtual appliance first and will likely need to do some minor tweaking of settings that aren’t captured by the WordPress Importer plugin. I usually find that these aren’t a major deal-breaker and, in the case of theme settings, can often be dealt with using the import/export functionality provided with the theme itself.

If you want to create an exact clone, the process isn’t too complex. Essentially, you will need to copy the entire WordPress file structure along with a dump of the mySQL database. Copying the WordPress files (which will include the /wp-content folder and all plugin and theme files along with your media files) is as simple as using FTP to connect to web host and downloading via your favorite FTP application. If your web host provides it, PHPMyAdmin provides a simple way to export your mySQL database. Once you have a copy of your WordPress files and mySQL database it is a simple matter to upload/import them to your LAMP virtual appliance.

Finally, there are also a few WordPress plugins designed to ease the task of cloning a WordPress website (disclaimer: I have no experience with any of these plugins). Remote administration services for WordPress such as ManageWP often include site cloning features as well.

Using Your Clone Website

Now that you have your clone website up and running, it is just a matter of installing updates on it and testing that all the necessary functionality of your website is retained. For this purpose, you may want to draw up a short list of critical website functionality to be checked. Once you have sucessfully verified updates on your clone website you can proceed to install them on your live website without fear of disaster.