A PHP 7 to 8 migration tool for WordPress sites: what it should do

By CompatNav · Published · Last reviewed · 3 min read

Short answer

For a WordPress site, a PHP 7 to 8 “migration” is mostly a check: find which plugin and theme code stops working on the PHP 8 version you choose, fix or replace it, then switch. A good tool checks every change from 7.4 up to your target, not just 8.0, because the host moves you straight to 8.3, 8.4 or 8.5. The free CompatNav plugin does that on your own server and tells you, for each plugin, whether an update fixes it or the code needs changing.

What “migration” means for a WordPress site

On a WordPress site you don’t migrate code by hand, file by file. Your host changes the PHP version, and every plugin and theme must cope with it. The migration is: find what won’t, fix it (update, replace or change the code), then switch. The tool you need is the one that does the finding well.

PHP 7.4 has had no security fixes since 28 November 2022 (php.net), so most sites still on it are moving now, often straight to 8.3 or later.

Check every step, not just 8.0

Your host switches 7.4 directly to the version you choose. But the changes of every version in between still apply: code that stops on 8.0 also stops on 8.5. PHP 8.0 has by far the longest list (php.net): removed functions such as create_function() and each(), curly-brace offsets, old-style constructors. The later versions add a few more breaks and many notices. The full map is in moving from PHP 7.4 to PHP 8.

What the tool should tell you, per plugin

  • Will it break, or only show notices? Fix the first group before switching; plan the second.
  • Is an update available? Often the developer has already fixed it.
  • Is it your own code? Custom code gets no update: someone has to change it.
  • Where exactly, and how to fix it: the file, the line, and an example.

How CompatNav does it

The free CompatNav plugin, on your server:

  1. Choose your target under Tools → CompatNav: 8.0 up to 8.5. It checks every change from your current version to that one.
  2. Scan every plugin and theme, read-only, with 58 checks.
  3. Read one verdict and a short “What to do first” list.
  4. Open each plugin: whether an update is available, whether the code looks like your own, each issue in plain words, and a before/after example for whoever maintains it.

A real finding, from one of the PHP 8.0 removals:

Code protected by function_exists() or a PHP version check is not reported, so the list stays short. And CompatNav says what it can’t see: problems that depend on values while the site runs, such as count() on something that isn’t a list.

Then switch

Fix what will break, test on a staging copy if you can, switch at a quiet time, and watch the error log for a week.

Key takeaways

  • You don’t install 8.0, 8.1 and so on one after the other; the host switches you to one version, and every change in between applies.
  • PHP 8.0 removed the most: create_function(), each(), curly-brace offsets, old-style constructors.
  • A migration tool for WordPress should check plugins and themes, not just your own code.
  • For each problem you need to know: is there an update, or must the code change?
  • PHP 7.4 has had no security fixes since 28 November 2022.

Frequently asked questions

Can a tool rewrite my plugins for PHP 8 automatically?

The free CompatNav plugin never changes code: it finds problems and shows a before/after example for each. CompatNav Pro adds suggested fixes for custom code as patch files, which a developer reviews and applies; nothing is applied automatically.

Should I go to PHP 8.0 first?

No need, and 8.0 gets no security fixes any more. Check for the version you want (8.3, 8.4 or 8.5) from 7.4; a check that covers every version in between gives the full picture in one go.

How long does a migration take?

The check takes minutes. The fixes depend on what it finds: updates are quick, custom code takes longer. Plan before your host’s date.

Check your own site before you upgrade

CompatNav is a free WordPress plugin. It reads the code of your plugins and themes on your own server and tells you, in plain words, what will break and what will only show notices on the PHP version you choose. It never changes your code. It can’t see problems that only appear while code runs with real data, so a quick check of your site after the upgrade still matters.

Get CompatNav on wordpress.org How it works

Sources

About the code examples: each output is the real output of the code shown, run with the official PHP builds, without a php.ini, with all errors reported and displayed. Only the file path was replaced by a neutral server path.