PHP7 and old WordPress websites will break. Here is how to fix it!

php7 wordpress

01 Mar PHP7 and old WordPress websites will break. Here is how to fix it!

The story

 
Last week I was contacted by a client who was working on behalf of another client. They had a issue with their WordPress website and knowing I had experience in WordPress, they reached out. The problem had started with their hosting company upgrading the server (hosting where the website files are stored) to a new version of PHP which is PHP7.

PHP is a dynamic coding language that is used to build websites and frameworks such as WordPress and like most active technology it evolves and updates with new features. But with adding new features they can also depreciate features. In PHP7 the latest version, they have removed the support of MySQL and in its place support MySQLi or PDO.

Now those may seem foreign to you, but these are what are known as databases. These are specific versions of a database and have integrated ways for PHP to talk to the database with MySQL connections. MySQL is old and insecure so it was updated to MySQLi. Not much of a change really in name, but it can change a lot within a website. The way it connects and and the code used is quite different.

So, the hosting company upgraded the server to PHP7, simple enough. WordPress can detect if MySQL is not enabled to then to use MySQLi. But the website was putting out this error:

“Your PHP installation appears to be missing the MySQL extension which is required by WordPress”.

After a little research it appeared it could of been an issue with an old plugin, but after ruling that out, it could only be an issue with WordPress and its core files itself. After accessing the FTP is was clear the website was build in 2010 and never updated.

WordPress was updated to handle MySQLi connections in version 4.4 which is not that long ago. But this website has never been updated and was running a really really old version of WordPress.  A version that was using MySQL without a fall back which was later added to WordPress.

Without keeping the website and its plugins updated regularly the website simply broke with the server upgrade to PHP7. All that would be displayed was an empty page with a warning.

I manually updated the files for WordPress via the FTP (File transfer protocol). This resolved the MySQL error message that was being produced. Note: Always take a backup of your files before overwriting!

What happened next was an internal 500 error. I checked the log files and saw that an out of date plugin was causing the 500 internal server error. I manually removed it by deleting the folder in the FTP and the website came back online.

The moral of the story is how important it is to keep your Plugins and your WordPress system up to date! As technology evolves and grows so does everything that is supported by it. In this case WordPress. I posted recently about a security issue with WordPress and why you need to keep it updated.

So how can you make sure this does not happen to your WordPress website?

The solution

 
Keep your WordPress website updated and check it often for new updates. Keep your plugins up to date too! Plugins are great features but they can also cause issues when they are out of date.

If you are having the same issue as mentioned above and you are locked out of the website with the same error message:

  • manually download WordPress, extract the files and overwrite your existing files via FTP.
  • Check your log files for errors.
  • Remove plugins to reduce any errors that are caused. A common plugin is Wordfence. It has been noted that with PHP7 update this plugin can cause issues.

 

If you do not feel comfortable to do the updates yourself then get in touch with experience WordPress professionals such as Digital Park who are more than happy to help!

No Comments

Post A Comment