How to test a WordPress site on a new PHP version before upgrading

2026-12-05来源 dev.toEnglish

You want to move WordPress to a newer PHP version, but core support doesn't tell you if your themes or plugins will work. Back up and update everything first, switch PHP on a staging site, and log errors before touching live. Here's the exact order to test the upgrade without breaking your live site.

Check your current PHP version and WordPress core support

Start by checking which PHP version your site runs today. From the WordPress Dashboard, open Tools > Site Health and select the Info tab. Expand the Server section and scroll down to PHP version.

If that number is PHP 8.3 or higher, you don't need to update PHP right now. Anything lower is below the recommended version and runs on an outdated and insecure PHP version, so it's time to update.

Each PHP release branch gets two years of active support from its initial stable release. After those two years, it gets two more years for critical security issues only. Once four years are up, the branch reaches end of life and is no longer supported. Users on an end-of-life release should upgrade as soon as possible because they may be exposed to unpatched security vulnerabilities.

Next, check that your WordPress version works with the PHP version you plan to test. WordPress 6.7 added beta support for PHP 8.4, and WordPress 6.9 added beta support for PHP 8.5. WordPress 7.0 dropped support for PHP 7.2 and 7.3, and use of the beta support label was retired in May 2026.

Even though WordPress itself works with PHP back to 7.4, core compatibility doesn't tell you if your themes or plugins will work on newer PHP. That's why checking your own stack comes next.

Back up and update everything before changing PHP

Make a backup of your site before you change anything. A backup lets you revert your site to its current state if anything goes wrong. Here's the catch that's easy to miss: restoring the backup alone isn't enough after a PHP change. To revert that backup, you also need your web host to move your PHP version back to your current version.

With a backup saved, open Dashboard > Updates and update everything across WordPress, your themes, and your plugins. Check that your site works after those updates before you touch PHP.

Next, make sure your themes and plugins are actively maintained. Check when each was last updated on its WordPress.org page or its developer's website. If one hasn't been updated in a long time, or its developer can't confirm it works with newer PHP, look on WordPress.org for one with similar functionality and use that instead.

Pre-scan installed plugins and themes for known PHP issues

Before switching PHP on staging, you can scan your installed plugins and themes to see where to focus testing. One free option we build at Bright Labs is Bright Labs Compatibility Scanner for PHP. It reads the code of every installed plugin and theme and lists each file and line that uses something removed or deprecated in the PHP version you pick, covering PHP 8.2 to PHP 8.5.

The scanner uses current PHPCompatibility rules and runs inside WordPress in short steps without exec() or shell access. Your code stays on your own server with no tracking, and the plugin makes no network request unless you turn on its optional update pre-scan, which is off by default. Because the scanner reads code without running it, it can miss problems in code built at runtime and flag fallback paths that never run on your site. Treat a clean result as a good sign, and still test the upgrade on a staging copy.

Switch PHP on staging and capture errors in debug.log

If your hosting company offers a staging site, update PHP there first and test your site before updating your live site. PHP runs on your website's server, so changing it means adjusting your host's settings or asking your provider to switch PHP for you. If your host doesn't include staging, WP_DEBUG and the other debug tools are also meant for local testing installs.

Before you click around on staging, turn on WordPress debug logging in wp-config.php. WP_DEBUG and the other debug tools are not recommended on live sites because they are meant for local testing and staging installs. Enabling WP_DEBUG causes all PHP errors, notices, and warnings to display, including notices about deprecated functions and arguments slated for deletion in the near future.

To capture everything without printing errors onto the page, pair WP_DEBUG with WP_DEBUG_LOG and turn off WP_DEBUG_DISPLAY. Inserting those constants in wp-config.php logs all errors, notices, and warnings to debug.log in the wp-content directory and hides them so they don't interrupt page generation. For WP_DEBUG_LOG to do anything, WP_DEBUG must be true, and you can toggle WP_DEBUG_DISPLAY independently. That setup also captures off-screen notices, such as those from an AJAX request or a wp-cron run, so you can review them later.

define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false ); 
  • Open your key public pages, search, and forms on staging after switching to the new PHP version.
  • Check Dashboard > Updates and your active theme and plugin pages to confirm they load without errors.
  • Trigger any actions that rely on AJAX requests or wp-cron runs so off-screen notices get written to debug.log.
  • Review debug.log in the wp-content directory to spot errors, warnings, and notices about deprecated functions and arguments.
  • Remember that PHP by default only shows fatal errors or a white screen of death, while WP_DEBUG surfaces warnings and notices for things that don't seem broken yet but fail proper data validation conventions inside PHP.
  • Update or replace any plugin or theme with unconfirmed PHP compatibility before you touch the live site.

Move the PHP upgrade to live with a rollback plan

Once your staging copy runs cleanly on the new PHP version, plan the same change for your live site. Make sure WP_DEBUG is turned off on production, since debug tools aren't recommended on live sites. Then change PHP in your host's settings or ask your hosting provider to update it for you.

Check your site right after the live PHP switch. If anything goes wrong and you need to restore your backup, contact your host first and ask them to restore the previous PHP version you had running. Once PHP is back on that previous version, restore your backup and fix the broken piece on staging.

Sources

Frequently Asked Questions

Does a clean compatibility scan mean my WordPress site will work on the new PHP version?

No. Bright Labs Compatibility Scanner for PHP reads code without running it, so it can miss issues in code built at runtime and flag code that never runs. Treat a clean result as a good sign, and test on a staging site before switching PHP live.

Should I leave WP_DEBUG turned on after testing a PHP upgrade?

No. WP_DEBUG and the other debug tools are not recommended on live sites because they are meant for local testing and staging installs. Keep WP_DEBUG turned off on production.

What if my host does not offer a staging site?

Back up your website first, update everything under Dashboard > Updates, and check on WordPress.org or each developer's website whether your themes and plugins are actively maintained. You can also test on a local install, and check how to switch PHP back to your previous version before restoring a backup if needed.

Why does debug.log show deprecated notices when my site still loads?

Enabling WP_DEBUG triggers notices about deprecated functions and arguments that have not been removed yet, alongside warnings and errors. By default PHP only displays fatal errors or a white screen of death, so WP_DEBUG surfaces notices for code that still runs for now.

Originally published on Bright Labs.

原文:https://www.a8q9.cn/en/article/how-to-test-a-wordpress-site-on-a-new-php-version-before-upgrading-7f7ceb.html

相关文章