Developer testing WordPress PHP 8.6 compatibility at a desk with code and a site preview on screen Developer testing WordPress PHP 8.6 compatibility at a desk with code and a site preview on screen

WordPress PHP 8.6 Compatibility: What Developers Need

WordPress 7.2 is compatible with PHP 8.6, but plugin and theme code still needs testing. Here are the changes developers should check, from stream wrappers to image flipping.

PHP 8.6 arrived on November 19, and a WordPress Core developer note published November 23 says WordPress 7.2 is compatible with it as of Beta 5. The core issues found during testing have been resolved, but plugin and theme compatibility remains an open question. This guide to WordPress PHP 8.6 compatibility identifies the code changes developers should review and how the WordPress team says to test.

The short version: WordPress 7.2 does not raise the minimum supported PHP version, which remains 7.4. Core’s known PHP 8.6 compatibility issues are fixed, but that does not confirm that every plugin or theme works on the new PHP version. Test your own extensions on WordPress 7.2 and PHP 8.6, with debugging enabled, before upgrading a production site.

WordPress PHP 8.6 compatibility: what changed

The November 23 developer note covers changes affecting font MIME types, custom stream wrappers, GD image flipping and object identifiers. It also calls out PHP 8.6’s new clamp() function. Some fixes are already in WordPress 7.2; others require plugin and theme authors to check their own code.

That distinction matters. WordPress Core’s compatibility work does not automatically update third-party code, and the note specifically describes the plugin ecosystem as an area that still needs attention.

Four areas plugin and theme developers should check

TrueType font MIME types

PHP 8.6 changes the MIME type reported for valid TrueType font files from font/sfnt to font/ttf. WordPress 7.2 now accepts both types for these files, and its font utility returns font/ttf.

Review code that checks specifically for font/sfnt. The developer note says to update those checks to accept font/ttf as well. It also points out that some older PHP builds linked to a system-installed libmagic may already return the newer type.

Custom stream wrappers and saving files

In PHP 8.6, fclose(), file_put_contents() and copy() return false when flushing or closing a stream fails. A custom PHP stream wrapper without a stream_flush() method can trigger that result, even if it wrote the data.

WordPress 7.2 checks the return value when its GD image editor saves to a stream. The note says a missing flush method can cause an image save error, while local filesystem saves are unaffected. If your plugin registers a stream wrapper, add stream_flush(); if there is nothing to flush, the note says the method should return true.

GD image flipping

PHP 8.6 updates GD to version 2.4.0. With that version, imagecopyresampled() returns an all-black image when called with negative dimensions. WordPress had used negative dimensions for GD image flips, so the change affected flipped images, including some JPEGs WordPress rotates automatically based on EXIF orientation. The Imagick editor was not affected.

WordPress 7.2 replaces that approach with PHP’s imageflip() function. Developers whose code uses negative dimensions with imagecopyresampled() for flipping should switch to imageflip(), as the Core note advises.

Object identifiers and the clamp() function

The note reports that a scan of the Plugin Directory found nearly 9,000 uses of spl_object_hash() across more than 2,300 plugins. It recommends replacing that function with spl_object_id(). Check how your code stores or compares the result: the replacement returns an integer rather than a 32-character string.

PHP 8.6 also adds clamp(), which limits a value to a range. WordPress has included a polyfill since version 7.1, so plugins and themes can use the function on supported PHP versions. The note flags one difference for exception handling: on PHP 7.4, the polyfill throws InvalidArgumentException, while PHP 8.6 can throw ValueError. Code catching these exceptions may need to handle both.

How to test a plugin or theme on PHP 8.6

The Core team says to run your plugin or theme on PHP 8.6 with WP_DEBUG and WP_DEBUG_LOG set to true. Its developer note also provides steps for using an 8.6-fpm image with the wordpress-develop local Docker environment.

WordPress 7.2’s test library includes a fix for a deprecated spl_object_hash() call in a PHPUnit helper. The note says test suites should run against PHP 8.6 only with WordPress 7.2 or later, because support for new PHP versions is not backported to older WordPress branches.

For a WordPress-specific PHP 8.6 bug, the Core team asks developers to open a Trac ticket with the php86 keyword. That gives the project a direct way to track compatibility reports.

What this means for site owners

WordPress 7.2’s compatibility status is a useful starting point, not a blanket assurance for the extensions on your site. Core’s known issues have fixes, but a plugin can still rely on a changed MIME type, use a custom stream wrapper without a flush method or contain code that behaves differently on PHP 8.6.

Before changing PHP versions on a live site, identify the plugins and theme your site depends on and test them with WordPress 7.2 on PHP 8.6. For developers, the practical next step is to run the extension’s test suite in that combination and inspect the debug log for failures.

FAQ

Is WordPress 7.2 compatible with PHP 8.6?

Yes. The WordPress Core developer note says WordPress 7.2 is fully compatible with PHP 8.6 as of Beta 5, with all known Core compatibility issues resolved at the time of publication.

Does WordPress 7.2 require PHP 8.6?

No. The minimum supported PHP version remains 7.4, according to the developer note.

Should I test my plugin on PHP 8.6?

Yes. The Core team recommends testing plugins and themes on PHP 8.6 with WP_DEBUG and WP_DEBUG_LOG enabled. It specifically advises running those tests with WordPress 7.2 or later.

Next step: run your plugin or theme tests on WordPress 7.2 and PHP 8.6, then review the debug log before planning a site upgrade.

Leave a Reply

Your email address will not be published. Required fields are marked *