The go-to resource for learning PHP, Laravel, Symfony, and your dependencies.

PHP Upgrade Impact on WordPress Plugins: A Developer's Guide


In 1880s Vienna, the city’s water supply system faced a critical challenge. The existing infrastructure could not reliably deliver clean water across the expanding metropolis. Engineers responded not with minor patches but with a comprehensive overhaul—replacing pipes, installing filtration systems, and reconfiguring distribution networks. The transformation required understanding which components could be upgraded incrementally and which demanded complete replacement.

The same is true when upgrading from PHP 7.4 to PHP 8.2 for a WordPress site. Some plugins will function flawlessly with minimal intervention. Others will require code changes or replacement entirely. In this guide, we’ll walk through a methodical approach to assess your plugin ecosystem, identify compatibility issues before they break your site, and execute the upgrade with confidence.

Understanding the PHP Version Landscape

Before we dive into the upgrade process itself, let’s establish what actually changes between PHP 7.4 and PHP 8.2. The journey from PHP 7.x to 8.x represents one of the most significant evolutions in the language’s recent history—and these changes affect WordPress plugins in specific ways.

PHP’s evolution introduced several breaking changes that impact WordPress plugins:

VersionKey Breaking ChangesTypical Plugin Impact
8.0Removal of create_function(), each(); TypeError on strlen(null)Fatal errors in older plugins using removed functions
8.1Deprecation of mysqli::real_escape_string without param, get_magic_quotes_gpc() removalStrict type errors, deprecation notices
8.2Deprecated dynamic properties, null/false/array standalone types changedE_DEPRECATED warnings, potential breakage in plugins using stdClass dynamically

Strictly speaking, PHP 8.0 introduced the most significant breaking changes—complete removal of several long-deprecated functions. PHP 8.1 and 8.2, by contrast, added mostly deprecations rather than removals. This distinction matters: upgrading to 8.0 requires more remediation effort than 8.1 or 8.2, though all three versions demand attention.

Why PHP Version Matters for WordPress Plugins

WordPress core maintains strong backward compatibility—code written for WordPress 5.x often works in 6.x with minimal changes. The plugin ecosystem, though, tells a different story. Each PHP version introduces changes that affect plugins in distinct ways:

  • Performance improvements: PHP 8.x demonstrates significant performance gains over 7.x in real-world WordPress workloads—often in the range of 50-100% faster execution. These improvements translate directly to page load times and server capacity.
  • Security enhancements: Newer PHP versions close known vulnerabilities, but these security improvements may break insecure implementations that relied on behaviors now considered unsafe.
  • Language evolution: Modern PHP adds useful features while removing deprecated constructs. Plugins using older patterns may encounter fatal errors when those constructs disappear.
  • Behavioral changes: Some code runs differently without any syntax changes—for instance, strlen(null) throws a TypeError in PHP 8.0 where it previously returned 0.

WordPress officially requires PHP 7.4+ as of version 6.0. Meeting only the minimum, though, leaves performance and security benefits on the table. PHP 8.2, for example, offers substantially improved performance and type safety—but these advantages come with compatibility responsibilities we must address.

Prerequisites

Before following this guide, you should have:

  • A WordPress site running PHP 7.4 or higher
  • Administrative access to your WordPress dashboard
  • Access to your hosting control panel or server command line
  • Basic familiarity with WordPress plugin management
  • FTP/SFTP or file manager access to your WordPress files
  • A recent backup of your site (or the ability to create one)

Of course, you don’t need deep PHP expertise—this guide explains each step as we go. What you do need is willingness to methodically assess and test before making changes to production.

Pre-Upgrade Assessment

Before changing any PHP version, we need to establish a baseline. The goal is to understand which plugins pose compatibility risks. We have several approaches available, each with trade-offs.

Checking Plugin Compatibility with Automated Tools

One common method is using the PHP Compatibility Checker plugin (available at https://wordpress.org/plugins/php-compatibility-checker/). This plugin scans your plugins and themes, flagging code that uses deprecated functions or incompatible syntax.

To use it:

  1. Install and activate the PHP Compatibility Checker plugin
  2. Navigate to Tools → PHP Compatibility
  3. Select the target PHP version (e.g., PHP 8.2)
  4. Run the scan

The plugin generates a report listing potential issues, typically categorized by severity and plugin.

Of course, this tool has limitations. It produces false positives for some patterns and may miss issues in obfuscated or compressed code. We’ll need to supplement it with manual testing—automated scanning alone isn’t sufficient.

Alternative Assessment Approaches

If you prefer not to use the PHP Compatibility Checker, or if you want to corroborate its findings, consider these alternatives:

  • Manual code review of critical plugins (especially custom or abandoned ones)
  • WP-CLI compatibility checks using third-party scripts that parse PHP syntax
  • Staging environment testing with error logging enabled (we’ll cover this in detail)

Each approach has trade-offs. The PHP Compatibility Checker is automated but imperfect. Manual review is thorough but time-consuming. A staging test is definitive but requires a full environment copy. In practice, we recommend using all three: start with automated scanning to identify obvious issues, then validate findings in staging where we can observe actual runtime behavior.

Building Your Staging Environment

A staging environment is essential—it’s a clone of your live site where we can test changes without affecting visitors. Most managed WordPress hosts provide one-click staging environments. If yours doesn’t, we can create one manually:

  1. Create a subdomain (e.g., staging.yoursite.com)
  2. Copy your WordPress files to the staging directory
  3. Export your database and import it into a new staging database
  4. Update wp-config.php with the staging database credentials
  5. Update WordPress site URL in the staging database (wp_options table)
  6. Password-protect the staging site to prevent indexing

Alternatively, plugins like WP Staging automate this process. The key is ensuring the staging environment mirrors production as closely as possible—same PHP version initially, same plugins, same content. We’ll change the PHP version in staging first, which is the whole point of having this isolated testing ground.

The Upgrade Walkthrough

Let’s walk through a complete upgrade with concrete examples. Suppose we have a WordPress site running PHP 7.4 with active plugins: WooCommerce, Contact Form 7, and a custom plugin called “my-custom-plugin”. We want to upgrade to PHP 8.1. We’ll use the staging environment we just built.

Step 1: Baseline Verification

First, we verify our current state. This gives us a reference point before making changes.

# Check current PHP version
php -v
# Output: PHP 7.4.33 (cli) ...

# Check WordPress plugin list via WP-CLI
wp plugin list --status=active
# Output (abbreviated):
# +-------------------------+----------+--------+---------+
# | name                    | status   | update | version |
# +-------------------------+----------+--------+---------+
# | woocommerce             | active   | none   | 7.9.0   |
# | contact-form-7          | active   | none   | 5.7.5   |
# | my-custom-plugin        | active   | none   | 1.2.3   |
# +-------------------------+----------+--------+---------+

Note which plugins are active. In our example, we have three active plugins—though the PHP Compatibility Checker might have revealed a fourth, “legacy-plugin”, that we didn’t realize was active. That’s why we’ll do thorough testing in the next steps.

Step 2: Run Compatibility Scan

We run the PHP Compatibility Checker for PHP 8.1 on our staging environment:

Scanning...
Progress: 100% (3/3 plugins)

Results:
- woocommerce: No issues found
- contact-form-7: 2 deprecation notices (low severity)
- my-custom-plugin: 1 fatal error risk (high severity)

The custom plugin uses create_function() on line 42—removed in PHP 8.0. That needs immediate attention. Though the severity is “high”, we’ll address it directly in the remediation phase. The Contact Form 7 deprecations are less urgent but worth noting for future compatibility.

Step 3: Backup

Before proceeding, we create a full backup. This isn’t optional—it’s our safety net if anything goes wrong.

# Database backup
wp db export backup-before-php-upgrade.sql

# Files backup
tar -czf wp-files-backup-$(date +%Y%m%d).tar.gz /var/www/html

We verify the backup exists:

ls -lh backup-before-php-upgrade.sql
# -rw-r--r-- 1 user user 245M Mar 16 10:30 backup-before-php-upgrade.sql

Note: The exact file size will vary, but the file should exist and be a reasonable size (tens to hundreds of megabytes depending on your site). If the backup is suspiciously small or missing, recreate it before proceeding.

Step 4: Upgrade PHP in Staging

In our hosting control panel, we change the PHP version from 7.4 to 8.1. Alternatively, via command line (for Ubuntu/Debian with update-alternatives):

sudo update-alternatives --set php /usr/bin/php8.1
php -v
# PHP 8.1.28 (cli) ...

The exact PHP 8.1.x version number may vary depending on your distribution’s packages. After switching, we confirm the change with php -v. If you’re using a hosting control panel, the interface will show the active version.

Step 5: Test in Staging

We enable debugging in wp-config.php on the staging site:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

Then we browse the staging site thoroughly—visit the homepage, product pages, contact forms, checkout if applicable, admin dashboard. We’re looking for any visible errors. Then we check wp-content/debug.log:

tail -f wp-content/debug.log

Suppose we see:

[16-Mar-2026 10:45:12 UTC] PHP Deprecated:  Function create_function() is deprecated in /wp-content/plugins/my-custom-plugin/includes/helpers.php on line 42
[16-Mar-2026 10:45:15 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function mysql_connect() in /wp-content/plugins/legacy-plugin/legacy.php:15

The first deprecation we expected from our scan. The second—mysql_connect()—is new. The mysql_* extension was removed in PHP 7.0, so this plugin should have been broken already. Yet it only manifested now because perhaps it was inactive in production, or error reporting was suppressed. This illustrates why staging testing is essential: we discovered an unknown problem before it hits production.

Step 6: Remediate

We have options for each issue:

For my-custom-plugin (our custom code, we control it):

  1. Update the plugin to replace create_function() with an anonymous function.

For legacy-plugin (abandoned plugin): 2. Replace it with a modern alternative if functionality is needed 3. Remove it if unnecessary 4. Fork and patch if critical and no alternative exists

Let’s update the custom plugin’s includes/helpers.php:

// Before (PHP 7.4, broken in 8.0+)
$func = create_function('$a', 'return $a * 2;');

// After (PHP 5.3+ compatible)
$func = function($a) { return $a * 2; };

For the legacy plugin, we find it hasn’t been updated in 8 years. We replace it with a maintained alternative or remove it if the functionality isn’t essential.

Step 7: Retest

After making changes, we clear any caches and retest:

wp cache flush
# Browse site thoroughly, test forms, checkout, etc.
tail -20 wp-content/debug.log
# No new errors—success

We continue browsing all critical user paths. If no new errors appear in the log and the site functions normally, our staging upgrade passes.

Step 8: Repeat in Production

Once staging passes, we repeat the process on production during low-traffic hours:

  1. Notify users of maintenance window (if applicable)
  2. Create fresh production backup (different from the one we made earlier)
  3. Upgrade PHP in production (control panel or command line)
  4. Verify site functionality
  5. Monitor error logs for 24-48 hours

Tip: Keep the staging environment running the upgraded PHP version for another week before production to catch any edge-case issues. Though we tested thoroughly, some problems only surface under real traffic patterns.

Troubleshooting Common Issues

Even with careful preparation, you might encounter issues. Let’s address the most common ones.

The White Screen of Death

A white screen usually indicates a fatal error. Enable debugging in wp-config.php if not already:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

Check wp-content/debug.log for the error. Typical fatal errors post-upgrade:

PHP Fatal error:  Uncaught Error: Call to undefined function mysql_connect()
PHP Fatal error:  Uncaught TypeError: strlen(): Argument #1 ($str) must be of type string, null given

The first indicates a plugin using the removed mysql_* extension—the solution is to migrate to mysqli or PDO, or replace the plugin. The second means a plugin called strlen(null)—changed behavior in PHP 8.0 that now throws TypeError. The fix is to ensure the argument is always a string, perhaps with (string) $var or checking for null first.

Resolution: Identify the plugin from the file path, then either update it, replace it, or patch it manually (if custom). If it’s an abandoned plugin with no replacement, you may need to downgrade PHP temporarily while seeking alternatives.

Deprecation Notices

These look like:

PHP Deprecated:  Function each() is deprecated in /wp-content/plugins/example/example.php on line 25

They don’t break functionality immediately but will break in future PHP versions. We should address them proactively:

  • Contact plugin developer with details and request an update
  • If plugin is abandoned, consider forking and fixing yourself (if feasible)
  • As temporary mitigation, suppress deprecation notices by setting error_reporting to exclude E_DEPRECATED in php.ini (but don’t ignore long-term)

Syntax Errors

Syntax errors prevent PHP from executing at all:

PHP Parse error:  syntax error, unexpected 'match' (T_MATCH) in /plugin.php on line 15

This indicates a plugin is using PHP 8.0’s match expression on a server running PHP 7.4 (or vice versa). The solution is to ensure the plugin’s code matches the target PHP version’s syntax capabilities—either upgrade the server PHP or modify the code to avoid newer syntax.

One may wonder: why would a plugin use match on PHP 7.4? The answer is that some plugins conditionally use newer syntax only when available, or the developer tested only on newer PHP versions and didn’t realize the syntax incompatibility.

Long-Term Maintenance

Once upgraded, staying current requires an ongoing strategy—but this isn’t about endless upgrade anxiety. It’s about sustainable practices:

  1. Enable automatic minor PHP version updates if your host supports it (PHP 8.1.x → 8.1.y). Minor releases are backward-compatible and contain security fixes.
  2. Test plugin updates in staging before production. Each plugin update could introduce new incompatibilities; catch them early.
  3. Remove abandoned plugins—they’re security risks regardless of PHP compatibility. Audit your plugin roster regularly.
  4. Document custom modifications to plugins so they survive updates. Consider contributing fixes upstream if possible.
  5. Consider PHP version pinning if you must stay on a specific version for compatibility, but plan migrations. Pinning indefinitely means missing security patches.

Of course, this guide focuses on the upgrade itself, not ongoing maintenance—but the two are inseparable. The upgrade is a project; maintenance is the habit that keeps that project from needing to be redone.

Conclusion

Upgrading PHP for a WordPress site requires methodical testing and remediation, not just flipping a switch. The process demands:

  • A compatibility assessment (with tools and manual review)
  • A staging environment for safe testing
  • Attention to error logs during testing
  • A fallback plan (backup, rollback procedure)
  • Ongoing monitoring after the upgrade

By following the walkthrough and principles outlined here, you can minimize disruption and gain the performance and security benefits of modern PHP. The alternative—staying on unsupported PHP versions—exposes your site to security risks and performance stagnation. The upgrade effort, while substantial, pays dividends in site reliability and speed.

Remember: the goal isn’t just to make the upgrade work today, but to establish practices that keep your site healthy for tomorrow’s PHP releases. The engineers of 1880s Vienna didn’t just fix the immediate water crisis—they built a system that could evolve with the city. We should aim for the same durability in our software systems.

Sponsored by Durable Programming

Need help with your PHP application? Durable Programming specializes in maintaining, upgrading, and securing PHP applications.

Hire Durable Programming