WordPress 7.2 Beta 5 is compatible with PHP 8.6, according to a Core developer note published November 23. That does not confirm that every plugin, theme or custom storage wrapper will work on the new PHP version. Developers can use the note to identify code patterns to review and plan tests before changing a site’s PHP version.
The post, “WordPress and PHP 8.6” by Jonathan Desrosiers, says all known PHP 8.6 compatibility issues in WordPress Core had been resolved when it was published. It outlines changes affecting font MIME types, custom stream wrappers, GD image processing and test suites. The minimum PHP version for WordPress 7.2 remains 7.4.
What WordPress PHP 8.6 compatibility means for developers
Core compatibility and extension compatibility are separate checks. WordPress 7.2 runs its full test suite against PHP 8.6, but the Core team recommends checking each site’s plugins and themes as well. The dev note gives specific examples of code that may need changes, so developers do not have to treat the version change as an unexplained risk.
The timing matters for teams preparing for WordPress 7.2. The note says support for new PHP versions is not backported to older WordPress branches. In particular, plugin test suites should run PHP 8.6 against WordPress 7.2 or later, rather than assuming older branches contain the same test-library fix.
Four PHP 8.6 changes to review
TrueType fonts use a different MIME type
PHP 8.6 updates its bundled copy of libmagic, changing the reported type for valid TrueType font files from font/sfnt to font/ttf. The Core change accepts both types for .ttf files, while WP_Font_Utils::get_allowed_font_mime_types() now returns font/ttf.
Review plugin and theme code that explicitly checks for font/sfnt. The dev note says those checks should also accept font/ttf. It also cautions that older PHP builds linked to the system’s libmagic can already return the newer type, so this is not necessarily limited to PHP 8.6.
Custom stream wrappers need stream_flush()
In PHP 8.6, fclose(), file_put_contents() and copy() return false when flushing or closing a stream fails. A user-defined wrapper without a stream_flush() method can therefore report a failed operation even when it has written every byte.
The note describes a concrete image-saving case: a GD image save to a wrapper without that method can fail with image_save_error, even if the data was written. The local filesystem is not affected. WordPress 7.2 now checks the relevant return values when GD saves to a stream, matching the Imagick editor’s behavior. Developers who register a wrapper should implement stream_flush(); if it has nothing to flush, the note says it should return true.
Use imageflip() instead of negative dimensions
PHP 8.6 includes GD 2.4.0, where imagecopyresampled() returns an all-black image when given negative dimensions. WordPress had used negative dimensions for image flips, so the GD editor now uses imageflip(). The Imagick editor was not affected.
Check plugin code that copies the earlier technique. The Core team recommends replacing calls to imagecopyresampled() with negative dimensions for flipping with imageflip(). The dev note also says the WordPress method now returns a WP_Error rather than throwing a generic TypeError when no valid image is loaded.
Replace spl_object_hash() in plugin code
The WordPress 7.2 test library replaces its remaining use of spl_object_hash(). The note says a brief scan found nearly 9,000 uses across more than 2,300 plugins. Developers are asked to use spl_object_id() instead, but should check any code that stores or compares the result: the replacement returns an integer, not a 32-character string.
PHP 8.6 also adds clamp(), a function for limiting a value to a range. WordPress has included a polyfill since version 7.1, so the function is available across supported PHP versions. One exception detail matters to code that catches errors: on PHP 7.4, the polyfill throws InvalidArgumentException, while PHP 8.6 uses ValueError.
How to test a plugin or theme
The Core note recommends running the plugin or theme on PHP 8.6 with WP_DEBUG and WP_DEBUG_LOG set to true. For plugin test suites, use WordPress 7.2 or later when testing PHP 8.6. This lets developers check their own code against the version of the WordPress test library that includes the compatibility fix.
When an issue appears to be specific to PHP 8.6 in WordPress, the note says to open a Trac ticket with the php86 keyword. Developers can also use the PHP 8.6 testing environment described in the post for wordpress-develop.
FAQ
Is WordPress 7.2 compatible with PHP 8.6?
Yes. The November 23 dev note says WordPress 7.2 has been fully compatible with PHP 8.6 since Beta 5. It also says the minimum supported PHP version remains 7.4.
Does Core compatibility guarantee plugin compatibility?
No. The note asks developers to check their sites, plugins and themes separately. It identifies code involving font MIME checks, stream wrappers, image flipping and spl_object_hash() for review.
Which WordPress version should I use for PHP 8.6 plugin tests?
Use WordPress 7.2 or later. The Core team says support for new PHP versions is not backported to older WordPress branches.
Next step: test your plugin or theme on PHP 8.6 with debugging enabled, then review any failures against the specific changes in the Core dev note.