PHP 8.2 Upgrade Could Break Your WordPress Site

By Mark Brinker 
Updated: July 22, 2024

By Mark Brinker  /  Updated: July 22, 2024

PHP 8.2 Upgrade Could Break Your WordPress Site

If you'd prefer to watch this on YouTube, click here.

This is a public service announcement for anyone with a WordPress website.

During the first few months of 2024, several of our clients' WordPress websites that we host and manage suddenly and unexpectedly crashed

Today I'm going to explain why all these sites crashed and how we resolved the issue. 

(NOTE: If you're reading this blog post and you're one of our clients, everything is fixed and all is well. This blog post is really meant for people or businesses that manage their own WordPress site and how upgrading to PHP 8.2 could produce catastrophic effects if not handled correctly or in a timely manner.)

How this problem started

In April 2024, I received an email from our web hosting company (HostGator) saying they are upgrading our servers to PHP 8.2.

In case you're not aware, PHP is the scripting language on a web server that processes your website's code to make it look like and function like ... well, a website.

Think of PHP like the operating system on your phone or computer. 

HostGator's letter goes on to say ...

Over the next few weeks, older versions of PHP will no longer be supported (and will be removed) and sites will be forced to adopt the newer supported version of PHP.

At our office, we've known for a while we'd eventually have to transition to PHP 8.2. We also knew there might be a few hiccups along the way because when we attempted to upgrade one of our client's sites to PHP 8.2 at the end of 2023, their site crashed. Fortunately, we were able to quickly get their site back online by simply rolling back to an earlier version of PHP (in this case, PHP 7.4). 

So we just tabled this PHP issue, since it wasn't "hair on fire" urgent. But we knew we'd have to get it taken care of eventually. 

We couldn't delay any longer

After being notified by our web hosting company about the mandatory update to PHP 8.2 in the very near future, we couldn't avoid this any longer and risk one or more of our clients sites going down.

Here's where we got thrown a curve ball, which could happen to you as well. 

At the same time HostGator notified us about the upcoming transition to PHP 8.2, .
we also learned that HostGator eliminated the option to roll back (i.e. downgrade) to a lower version of PHP if something goes wrong.

This meant, once we flipped the switch to PHP 8.2, there was no turning back. If a site crashed, we were up the creek without a paddle. 

Here's the critical part

If you manage your own WordPress website and you get a notice from your hosting company telling you to upgrade to PHP 8.2, make sure you have the ability to roll back to a prior version like PHP 7.4 if your site crashes. 

If you find out you can no longer roll back to an earlier version of PHP because your hosting company disabled that feature, you're going to need to put a copy of your website on a staging server (basically a website "workspace" environment) where you can test things out and see whether or not your site is compatible with PHP 8.2.

This way, if your site crashes on a staging server — no harm, no foul — because it was only a copy of your site.

You never want to implement major changes or do significant testing on a live website, just in case something goes wrong and there's irreversible damage to your site.

With our situation, because we could no longer roll back to an earlier PHP version if something broke, we had to make a clone of each client's site, put it on a staging server, flip the switch, upgrade to PHP 8.2, then sit back and see what happened. Yes, this took a lot of time, but we didn't have another choice because we couldn't risk any client's site crashing.

Here's what we discovered

The good news is about 50% of our clients' sites passed with flying colors. The bad news is about 50% of our client sites crashed when we upgraded to PHP 8.2 — which was WAY more than I expected. 

In case you're wondering, we use name brand, premium digital components on all websites we build, which made things even more puzzling. 

I'm not going to bore you with all the gory technical details, but after hours of testing, we finally isolated the problem to the following:

  • WordPress plugins. Certain plugins were incompatible with PHP 8.2 and caused a site to crash. Once we removed the defective WordPress plugin(s), the site ran just fine with PHP 8.2.
  • WordPress themes. If a site crashed because a WordPress theme wasn't compatible with PHP 8.2, there were three options: (A) Isolate the code in the WordPress theme that's causing the site to crash and fix the code. This is what ended up being the solution for us. If you don't want to mess around with analyzing code, the next option is, (B) See if the WordPress theme developer has a theme update. Some will, some won't. The third option, (C) If you're unable to fix the code in a defective theme or the developer does not have a theme update, you might have to rebuild your site from scratch. 

Conclusion

Don't think this can't happen to you because that's exactly what we thought.

Sooner or later, your hosting company will upgrade your web server to PHP 8.2 and most likely require you to use PHP 8.2. 

As soon as you are able, I'd strongly advise testing your site to see if it's compatible with PHP 8.2. Don't make the same mistake we did and just assume PHP 8.2 would automatically work with your site, because it might not.

If you'd like to take a deeper dive on this whole PHP 8.2 thing, here's a really good resource from our friends over at Forge and Smith

About the Author

Mark Brinker is president of Mark Brinker & Associates — a business website design and development firm in Sterling Heights, MI. Mark offers a FREE masterclass training, "The 5 Steps To Creating A Website That Consistently Attracts Ideal Clients", which you can watch here. Mark also publishes lots of great (and free!) content on his YouTube channel.

Leave a Comment

Your email address will not be published. Required fields are marked *


Comment *

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}