Do you have a good idea of what PHP version your clients’ websites are on? I’m sure you’ve heard about PHP 8 which was released at the end of 2020. I, as well as you, know we should be upgrading our websites regularly. But for me to actually perform the task is a different story.
It might feel complicated or intimidating, to go through the upgrade to PHP 8 for all your clients’ sites. Maybe you have several hundred sites and the task feels overwhelming, or maybe you just don’t know what to do. If you need help getting started, we have written this detailed guide just for you. However, if you are still unsure if you should take this on and you want a quick overview of what the potential pitfalls are, then keep reading.
At WLA we have over 10 years of experience working with WordPress and we develop about 3000 projects every year. Since PHP 8 was released two years ago, my colleagues and I have been contacted by many marketing agencies. They are asking us to help them upgrade their sites and their clients’ sites. Some of them don’t have the development skills necessary to get this done in-house or they have run into issues when trying to do the upgrade.
We have supported these agencies and have helped them with whatever is necessary, be it code updates or custom rebuilds. We have collected the concerns of our customers and we want to share what we have learned with you.
This is what we have learned
It turns out that upgrading is not as easy as clicking a button. In fact, the upgrade may require you to take several steps to prepare for the upgrade to PHP 8, as well as perform certain fixes after the fact.
These are the top 5 issues I have run into and some tips on how to avoid or deal with them.
1. Themes stop working
If your theme stops working, it is likely the theme is not compatible with PHP 8. This can occur with themes that are no longer supported by the original author or if a custom theme was used to originally create the website.
The source of the problem is most likely deprecated functions written into the PHP code. Typically, these functions are modified and updated with newer and more efficient versions as the code evolves. However, if the code in your theme is not updated to account for these changes it can have adverse effects or even take the website down.
Check if the theme is updated to the latest version, consider updating it if there is a newer version available. If updating the theme is not an option for you, you may have to work with a developer to rebuild the site.
2. Plugins stop working
You might run into issues with your plugins. This might be the result of a plugin that has not been updated for a long time. Check when the latest update was performed and if it is still supported via the plugin page in WP Admin:
If the plugin is still supported, make sure to update your plugins before checking for compatibility.
One of the main reasons the plugin may not work anymore is that the plugin uses create_function which is not supported by PHP 8. You may want to consider replacing the plugin with a different one or creating a custom plugin with the help of a developer. I recommend reading this article about how to find the best WordPress plugin if you are considering replacing a plugin that is incompatible with PHP 8.
3. Syntax error
With the upgrade to PHP 8 we got many new features, including major changes to the syntax. This means that older code may not properly run and an error message will appear over your website content instead of what it is supposed to display. Typically the error message gives a brief description and lists its location within the code to assist the developer.
4. Composer package is not supported
Some composer packages have pieces of code that are not supported by PHP 8. This may need to be manually updated or fixed. You might find it useful to check which among the packages requires a certain PHP version.
5. Database connection errors
Occasionally a PHP update can cause database connection issues. The updated PHP may require an increased memory limit and changes to the wp-config.php file or other troubleshooting is required.
Is upgrading to PHP 8 really necessary?
If you are like me, you might feel tempted not to upgrade to PHP 8, but there are good reasons why you should. Besides the benefits that come with the latest PHP version, here are some things that you should consider before you decide to postpone it to a later date.
- You are running the risk that your site(s) will break or run into issues later on, or that you won’t be able to update themes and plugins in the future
- Better security. The new PHP version includes some security patches that help keep your sites secure, additionally having updated themes and plugins are always less vulnerable than outdated ones.
- Your hosting provider may demand it, alternatively, they might force the upgrade on you causing your sites to break
- Your web development agency might require it for them to be able to provide you with maintenance or other services
There are many good reasons for upgrading your sites to PHP 8. I have just outlined some of the main ones here. But the upgrade might not be a walk in the park. Keep in mind that your WordPress sites are reliant upon the compatibility of plugins, themes, and many more components. Unless you have a skilled developer close at hand, making the upgrades yourself might not be the most time and cost-effective solution. I would recommend you work with a developer that has experience with upgrading to PHP 8, to save you unnecessary headaches.