Dev.to WebDev πŸ›  Dev πŸ‘ 0 πŸ“– 2 min read

How to check if your WordPress plugins will break on PHP 8.4 (before your host upgrades you)

Hosting companies keep retiring old PHP versions. When yours moves a site from 7.4 or 8.1 to 8.3 or 8.4, the question is always the same: which plugin is going to take the site down? You can find out before the switch.

Hosting companies keep retiring old PHP versions. When yours moves a site from 7.4 or 8.1 to 8.3 or 8.4, the question is always the same: which plugin is going to take the site down?

You can find out before the switch. This is the short version of how.

The tool most people find first is abandoned

The plugin most people install for this, WP Engine's PHP Compatibility Checker, has carried a "no longer actively maintained" notice on WordPress.org since 2023. It only checks code up to PHP 8.0 and was last tested with WordPress 6.4.

So a plugin that breaks on PHP 8.2 or 8.4 can come out of it looking clean. That is worse than having no tool at all.

What a useful scan has to tell you

  1. Breaks vs. deprecations. A removed function stops the site with a fatal error. A deprecation only writes a line in the error log and keeps running. A report with 400 mixed findings is noise; you need to know which lines are fatal on the version you are moving to.
  2. No false alarms for guarded code. Code wrapped in function_exists() or version_compare( PHP_VERSION, ... ) is already safe and should not be reported as a problem.
  3. It has to finish on shared hosting. WooCommerce alone is about 3,600 PHP files. A scan that runs in one request dies at the 30-60 second limit of shared hosts. It has to work in batches and resume.
  4. Your code stays on your server. No exec() (disabled on most managed hosts) and no uploading plugin code to an external service.

A free way to do it

I built Upgravo for exactly this, because I needed it for my own sites. It is free on WordPress.org:

  1. Install it from Plugins > Add New (search "Upgravo") or from wordpress.org/plugins/upgravo.
  2. Open Upgravo in the admin menu, pick the PHP version you are moving to (8.1 to 8.5) and run the scan. It runs in short batches with a progress bar; you can close the tab and come back.
  3. Read the verdict per plugin and theme:
    • Breaks: fatal on the target version, with file and line.
    • Notices: deprecated, still runs. Fix when you can.
    • Hidden: findings that do not apply (guarded code, or already true on your current PHP), with the reason.
  4. If something breaks, check whether the plugin has an update first. Usually the author already fixed it.

It also flags the most common PHP 8.2 notice that the standard rule set misses: Creation of dynamic property. There is a CSV export and a WP-CLI command (wp upgravo scan) for scripted runs.

What no scanner can do

A scanner reads source code; it does not run it. Errors that depend on real data (a null where a string was expected, for example) only show up when the code runs. So the safe order is: scan, fix what breaks, switch PHP on a staging copy, click through the site, then switch production.

A longer checklist, with the specific PHP 8.2-8.4 errors and how to read them, is on phpready.com/guides.

Disclosure: I'm the author of Upgravo.

πŸ“° Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.