5 kinds of WordPress plugins that cause PHP upgrade errors (and how to fix them)

By CompatNav · Published · Last reviewed · 5 min read

Short answer

The plugins that break on a PHP upgrade are rarely the popular, maintained ones. They are, in order to check: abandoned plugins that haven’t been updated in years; custom plugins written for your site; plugins bought outside wordpress.org whose updates stopped arriving; plugins that need a PHP extension the new version doesn’t include, such as IMAP on PHP 8.4; and plugins that bundle an old library. For each, the fix is an update, a replacement, a developer, or a word with your host. A check that reads every plugin’s code for the version you’re moving to tells you which of yours are concerned.

1. Abandoned plugins

What goes wrong: code written for PHP 5 or 7 uses things PHP 8.0 removed. Every call is a fatal error, and the page stops:

wp-content/plugins/old-slider/old-slider.php

<?php
$slides = [['title' => 'Team', 'order' => 2], ['title' => 'Welcome', 'order' => 1]];
$by_order = create_function('$a, $b', 'return $a["order"] - $b["order"];');
usort($slides, $by_order);
echo 'First slide: ', $slides[0]['title'], "\n";

Output on PHP 7.4.33

Deprecated: Function create_function() is deprecated in /var/www/html/wp-content/plugins/old-slider/old-slider.php on line 3
First slide: Welcome

Output on PHP 8.0.30the script stopped

Fatal error: Uncaught Error: Call to undefined function create_function() in /var/www/html/wp-content/plugins/old-slider/old-slider.php:3
Stack trace:
#0 {main}
  thrown in /var/www/html/wp-content/plugins/old-slider/old-slider.php on line 3

How to spot them: on wordpress.org, the plugin page shows when it was last updated and which WordPress version it was tested up to. In your admin, a plugin that never shows an update in years is a candidate.

The fix: replace it with a maintained plugin. Patching abandoned code yourself works until the next problem; create_function() and each() rarely come alone.

2. Custom plugins written for your site

What goes wrong: the same old code as above, with a twist: no update will ever arrive, because only the person who wrote it can change it. Some failures are silent: very old constructor syntax simply stops running on PHP 8.0, and the error appears somewhere else.

wp-content/plugins/old-slider/includes/class-slider.php

<?php
class Slider {
    private $slides;

    public function Slider() {
        $this->slides = ['welcome.jpg', 'team.jpg'];
    }

    public function count_slides() {
        return count($this->slides);
    }
}

$slider = new Slider();
echo 'Slides: ', $slider->count_slides(), "\n";

Output on PHP 7.4.33

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Slider has a deprecated constructor in /var/www/html/wp-content/plugins/old-slider/includes/class-slider.php on line 2
Slides: 2

Output on PHP 8.0.30the script stopped

Slides:
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /var/www/html/wp-content/plugins/old-slider/includes/class-slider.php:10
Stack trace:
#0 /var/www/html/wp-content/plugins/old-slider/includes/class-slider.php(15): Slider->count_slides()
#1 {main}
  thrown in /var/www/html/wp-content/plugins/old-slider/includes/class-slider.php on line 10

The fix: a developer changes the code, from a list of exactly what breaks: custom plugins and PHP 8 explains how to get that list, and old-style constructors this particular case.

3. Plugins bought outside wordpress.org

What goes wrong: a premium plugin updates through its seller, not through wordpress.org. If the licence, account or seller is gone, updates quietly stop, and the site keeps an old version whose code was never adapted to newer PHP.

How to spot them: in Plugins, look at the version against the seller’s current one, and check whether the seller still exists and your licence is active.

The fix: renew and update, or replace. Never install copies from unofficial sources to get updates: you can’t know what was changed in them.

4. Plugins that need a PHP extension

What goes wrong: the code is fine, but the PHP version doesn’t include something it relies on. PHP 8.4 moved IMAP, OCI8, PDO_OCI and PSpell out of PHP: they “have been moved to PECL and are no longer part of the PHP distribution” (php.net). A plugin that reads a mailbox through IMAP works on PHP 8.3 and stops on 8.4 if the host doesn’t install the extension:

wp-content/plugins/mail-inbox/mail-inbox.php

<?php
echo function_exists('imap_open') ? 'IMAP available' : 'IMAP missing', "\n";
$inbox = imap_open('{mail.example.com:993/imap/ssl}INBOX', 'user', 'password');

Output on PHP 8.4.26the script stopped

IMAP missing

Fatal error: Uncaught Error: Call to undefined function imap_open() in /var/www/html/wp-content/plugins/mail-inbox/mail-inbox.php:3
Stack trace:
#0 {main}
  thrown in /var/www/html/wp-content/plugins/mail-inbox/mail-inbox.php on line 3

The fix: ask your host to install the extension for PHP 8.4, or use a plugin that doesn’t need it. No code check can see this one: it’s about the server. IMAP and PHP 8.4 has the details.

5. Plugins with an old bundled library

What goes wrong: many plugins ship third-party libraries inside them, typically in a vendor folder. The plugin itself may be current while the copy of the library is years old. A library that still defines __autoload(), for example, makes PHP 8.0 refuse the file:

How to spot them: the path in the message or the finding continues into a vendor/ or lib/ folder inside the plugin.

The fix: the plugin’s developer updates the library. Don’t replace files inside a plugin yourself: the next update undoes it.

Find yours before you switch

Popular, maintained plugins are rarely the problem. CompatNav’s page on wordpress.org: “Well-maintained plugins often have nothing to report.” On three of the most-installed plugins together (about 7,800 PHP files), it reported 27 items for an upgrade from PHP 7.4 to 8.5, all of them deprecation notices.

To find the ones on your site, check every plugin and theme for the PHP version you’re moving to. CompatNav, free on wordpress.org, does it on your own server for PHP 8.0 to 8.5: per plugin and theme, whether an update is available, whether the code looks like your own, and each finding labelled “Will break” or “Deprecation notice”. Kinds 1, 2, 3 and 5 show up there; for kind 4, ask your host. Checking a plugin’s PHP compatibility covers the other ways to find out.

Key takeaways

  • Abandoned plugins: old code that newer PHP versions removed, such as create_function(). Replace them.
  • Custom plugins: nobody updates them for you; a developer has to, and some failures are silent.
  • Plugins bought outside wordpress.org: their updates come from the seller, so check that yours still arrive.
  • Plugins that need an extension, like IMAP on PHP 8.4: a server question for your host, not a code fix.
  • Plugins with old bundled libraries: the plugin looks current, the library inside it isn’t.

Frequently asked questions

Can you name the plugins that break on PHP 8?

No list stays right: each plugin version is different, and the one you run may already be fixed, or not. That’s why the answer has to come from your own site: check the versions you have installed, for the PHP version you’re moving to.

Are popular plugins safe?

Usually, when they’re up to date. On three of the most-installed plugins (about 7,800 PHP files together), CompatNav found 27 items for an upgrade from PHP 7.4 to 8.5, all of them deprecation notices, nothing that would stop a page.

What about my theme?

The same five kinds apply, and a broken theme affects every page. See checking a custom theme’s PHP compatibility.

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.