PHP 8.6 Deprecations: What Will Actually Hit Your WordPress Plugins and Themes

PHP 8.6 Deprecations: What Will Actually Hit Your WordPress Plugins and Themes
PHP 8.6 Deprecations: What Will Actually Hit Your WordPress Plugins and Themes

Switch a WordPress 7.0 site to PHP 8.6 and the first deprecation in your log comes from WordPress core, not a plugin. This guide covers the 8.6 deprecations that actually touch WordPress code, the exact notices, the replacements, and how to find them before your host flips the switch.

PHP 8.6 deprecations show up the moment you switch. On WordPress 7.0 with PHP 8.6.0, register any action with an object method as the callback and this is the first line you get:

Deprecated: Function spl_object_hash() is deprecated since 8.6, consider using spl_object_id() instead in /wp/wp-includes/plugin.php on line 1014

That line is WordPress core. It comes from _wp_filter_build_unique_id(), which runs every time add_action(), add_filter(), remove_filter() or has_filter() sees a callback like array( $this, 'init' ). On a real site that is hundreds of calls per page load. Your log fills up before your own code gets a turn.

PHP 8.6.0 was released on November 19, 2026. The full deprecation list is long, and php.net covers it well. This post is the WordPress cut: which items actually show up in plugin and theme code, the exact notice for each, the replacement, and a grep you can run tonight.

What “deprecated” means in PHP 8.6

Nothing on this list breaks your site today. A deprecated function still runs and still returns the same thing. PHP just raises an E_DEPRECATED notice every time it is used. Removal is planned for PHP 9, and PHP 9 has no release date.

It still matters, for three reasons:

  • Noise hides real errors: a log with 4,000 deprecation lines is a log nobody reads, and the one fatal error in it goes unnoticed.
  • Display leaks: if display_errors is on in production, visitors see the notices. Fix that setting either way.
  • Some of these are bugs: a few deprecations flag code that never did what its author thought. The is_a() section below is the clearest example.

Fix number one: update WordPress core

Before you touch a plugin, check your core version. We compared the WordPress source across versions on November 23, 2026:

  • WordPress 7.0.x: calls spl_object_hash() in wp-includes/plugin.php and twice in class-wp-widget-factory.php, plus the old type-check aliases in functions.php, the bundled IXR library, PclZip, class-ftp.php and getID3.
  • WordPress 7.1.0 through 7.1.5: the hook code switched to spl_object_id() in 7.1.0. One is_integer() call is left in getID3’s QuickTime module, which only runs when WordPress reads metadata from a QuickTime or MP4 file.
  • WordPress 7.2: the current 7.2 development source, past RC1, is clean. 7.2 is due December 8, 2026, and its Beta 5 announcement says all known PHP 8.6 compatibility issues have been resolved.

If you are on 7.0, update to 7.1.5 first, then test. Chasing plugin notices on a 7.0 install means sorting through core noise for no reason.

The type-check aliases

These are the ones you will actually find in WordPress plugins, usually in code written a long time ago. PHP 8.6 deprecates four aliases, and each notice names its replacement:

  • is_integer() and is_long(): Function is_integer() is deprecated since 8.6, use is_int() instead
  • is_double(): Function is_double() is deprecated since 8.6, use is_float() instead
  • doubleval(): Function doubleval() is deprecated since 8.6, use floatval() instead

The replacements behave identically, so this is a pure rename. Here is a small price helper written with the modern names, the way it should read after the fix:

PHP
<?php
/**
 * Normalize a price value from a form field.
 *
 * @param mixed $raw Raw input value.
 * @return float|null Price as a float, or null when it is not numeric.
 */
function dt_normalize_price( $raw ) {
	// Was: is_integer( $raw ) || is_double( $raw ).
	if ( is_int( $raw ) || is_float( $raw ) ) {
		return (float) $raw;
	}
	if ( is_numeric( $raw ) ) {
		// Was: doubleval( $raw ).
		return floatval( $raw );
	}
	return null;
}

spl_object_hash() to spl_object_id()

This is the one most likely to show up in bundled libraries. The notice reads Function spl_object_hash() is deprecated since 8.6, consider using spl_object_id() instead.

There is a catch, though. spl_object_hash() returns a 32-character string. spl_object_id() returns an integer. If you use the result as an array key, the swap changes how PHP treats that array, and array_merge() renumbers integer keys. We ran it: two objects keyed by spl_object_id() had keys 1,2, and after array_merge() they became 0,1. Every lookup by object ID is now wrong, silently.

WordPress hit the same problem. Version 7.1.1 added a prefix to the hook ID so it is never cast to an integer array key. Do the same. This registry keeps one entry per object and survives a merge:

PHP
<?php
/**
 * Build a stable array key for an object.
 *
 * The string prefix keeps PHP from treating the key as an integer,
 * so array_merge() and friends will not renumber it.
 *
 * @param object $instance Any object.
 * @return string Array key unique to this object while it exists.
 */
function dt_object_key( $instance ) {
	return 'obj_' . spl_object_id( $instance );
}
$registry = array();
$registry[ dt_object_key( $widget ) ] = $widget;

One honest note: both functions can reuse an ID once an object is destroyed. If your old code relied on the hash being unique forever, it was already wrong. The switch does not fix that and does not make it worse.

The rest of the PHP 8.6 deprecations, with replacements

The bulk of the PHP 8.6 deprecations come from one RFC where each item was voted on separately and needed a two-thirds majority. Most will never appear in a WordPress plugin. These are the ones that might:

  • define() with a third argument: case-insensitive constants have been gone since PHP 8.0, and the argument was already ignored. PHP 8.6 says so out loud. Delete the argument.
  • strcoll() and SORT_LOCALE_STRING: PHP points you to the Collator class from the intl extension, using Collator::compare() or one of its sort methods. Check that your host has intl before you ship that change.
  • metaphone(): there is no replacement in PHP itself. The notice says to use a userland phonetic matching library. If a search plugin relies on it, that is a Composer dependency, not a one-line fix.
  • spl_classes(): use ReflectionExtension::getClassNames().
  • mysqli_stmt_init() and mysqli::stmt_init(): use $mysqli->prepare(), which returns a ready statement. Plugins that go through $wpdb are not affected. WordPress core does not call either one.
  • mysqli_get_charset(): the PHP manual points to mysqli_character_set_name().
  • Objects where arrays are expected: passing an object to array_walk(), array_walk_recursive(), http_build_query() or mb_convert_variables() is deprecated, and so are object options for the compression functions and filters. Convert with get_object_vars() first.
  • Reserved names: let and is as class, function or constant names, readonly as a function name, namespace as a class constant name, and _ as a constant name.

The object-to-array fix needs one extra line, because array_walk() takes its array by reference, and handing it a function call directly gets you an “Only variables should be passed by reference” notice:

PHP
<?php
$args = (object) array(
	'paged' => 2,
	's'     => 'csv',
);
// Was: http_build_query( $args ).
$query = http_build_query( get_object_vars( $args ) );
// Was: array_walk( $args, ... ). Assign first, array_walk() needs a variable.
$vars = get_object_vars( $args );
array_walk(
	$vars,
	function ( $value, $key ) {
		echo esc_html( "{$key}={$value}" ) . "\n";
	}
);

If your old callback modified values by reference, it used to change the object. Now it changes a copy. Write the values back if you need them.

The deprecation that is really a bug report

is_a() and is_subclass_of() with a class name string, when $allow_string is false, now raise Calling is_a() with a string when $allow_string is false (or the same message naming is_subclass_of()). And that call has always returned false. We checked on PHP 8.5. A plugin doing is_a( $class_name, 'WP_Widget' ) with a string has been getting the wrong answer for years. Pass true as the third argument and the check starts working:

PHP
<?php
// Always false for a string, before and after 8.6. Now also deprecated.
$is_widget = is_a( $class_name, 'WP_Widget' );
// Correct: allow the first argument to be a class name.
$is_widget = is_a( $class_name, 'WP_Widget', true );

Two that fire before your code runs

Returning from a finally block and returning a value from __construct() are both deprecated, and both are raised when PHP compiles the file. We loaded a file with a function and a class that were never called or built, and PHP 8.6 printed Returning from a finally block is deprecated and Returning a value from a constructor is deprecated before the first line of output.

The finally one deserves fixing anyway. A return there silently overrides whatever the try block returned, and can swallow exceptions. Do the cleanup in finally and return after it:

PHP
<?php
/**
 * Fetch remote data and always release the lock.
 *
 * @return string|false Remote data, or false on failure.
 */
function dt_fetch_with_cleanup() {
	$result = false;
	try {
		$result = dt_remote_call();
	} finally {
		dt_release_lock();
	}
	return $result;
}

From other RFCs

The php.net release notes list a few more deprecations that came from separate proposals:

  • The mbstring regex functions: mb_ereg(), mb_split() and the rest of the family. The replacement is preg_ functions with the u modifier. Our mbstring refactoring guide covers the older alias cleanup. On 8.6, go one step further and move those mb_ereg() calls to preg_.
  • Constructors and destructors: returning a value from __construct() or __destruct(), or making them generators.
  • __debugInfo(): declaring a nullable return type.
  • Filter chains: more than 16 php://filter filters without setting filter.max_filter_count.

The rarely hit leftovers, back in the main RFC: Reflection setters and invokers called with the wrong types, the SplFileObject CSV methods, the ArrayIterator methods inherited from ArrayObject, and custom session handlers without create_sid() and validateId(). If you parse CSV files through SplFileObject, that one matters more than it sounds, and our fgetcsv() $escape guide covers what to do about it.

Not deprecations, but they still bite

PHP 8.6 also changes some defaults and return values. None of these raise a notice, which makes them easier to miss:

  • Session defaults: session.use_strict_mode and session.cookie_httponly are now on, and session.cookie_samesite is Lax. The PHP 8.5 image reported 0, 0 and an empty string. Only plugins that call session_start() care, and most of them should be happy about it.
  • trim() strips form feeds: trim(), ltrim() and rtrim() now remove \f by default. Our test string went from 3 characters to 1.
  • Write failures: fclose(), file_put_contents() and copy() now return false when flushing or closing the stream fails. If you ignored the return value, nothing changes. If you checked it, you may finally see errors that were always there.
  • More ValueErrors: many functions now throw on out-of-range values, invalid flags or NUL bytes. This post does not list them all. Test with real input.

Find them in your plugins and themes

Most of these are function calls, so grep finds them. Run this from your WordPress root. The quotes matter if your shell is zsh:

Bash
grep -rnE '\b(is_integer|is_long|is_double|doubleval|spl_object_hash|spl_classes|strcoll|metaphone|mysqli_stmt_init|stmt_init|mysqli_get_charset|get_charset|mb_ereg[a-z_]*|mb_regex_[a-z_]+|mb_split)\s*\(' \
  wp-content/plugins wp-content/themes --include='*.php'
grep -rn 'SORT_LOCALE_STRING' wp-content/plugins wp-content/themes --include='*.php'

On our own local WordPress install, spl_object_hash() turned up in 9 files across 4 plugins, and every one of them was a bundled library: Guzzle, Carbon, a Symfony PHP 7.2 polyfill and phpseclib. is_integer() turned up in 6 files, and 4 of those were plugin code, not a vendor folder. There were zero real mb_ereg() calls, but a looser grep for the bare string mb_ereg found 3 files that only mention it in polyfill comments.

A grep hit is not a runtime notice. That Symfony polyfill only defines its fallback when spl_object_id() does not exist, which means PHP older than 7.2. It will never run on 8.6. Other hits sit behind function_exists() checks or in code paths you never reach.

The compile-time ones cannot be grepped reliably, but the linter catches them. Because PHP raises them while compiling, php -l on 8.6 reports the finally return, the constructor return, let and is as function or class names, readonly as a function name, and namespace as a class constant name. It is the same trick that finds every implicitly nullable parameter on 8.4. If you do not have 8.6 installed, the official Docker image works. Run it from wp-content, not the WordPress root. Otherwise core’s php-compat/readonly.php shows up, and PHP 8.1 and later never even load that file:

Bash
docker run --rm -v "$PWD":/p -w /p php:8.6-cli sh -c \
  "find . -name '*.php' -print0 | xargs -0 -n1 php -d error_reporting=-1 -d display_errors=stderr -l 2>&1 | grep -i deprecated"

In our test it missed the constant names. let, is and _ declared as constants only showed up at runtime, so grep for those if you want to be thorough.

The checklist

  1. Update core: any 7.1.x release drops the spl_object_hash() calls, and 7.2 removes the last alias.
  2. Run the grep and the lint: both commands above, on a copy of wp-content.
  3. Split your code from vendored code: anything under vendor/, libraries/ or third-party/ inside a plugin belongs to someone else.
  4. Run staging on 8.6: turn on WP_DEBUG_LOG, click through the admin and the frontend, run a cron event, and read the log.
  5. Report vendored hits upstream: send the plugin author the exact notice. Do not patch their bundled library, because the next update overwrites your fix.

If this is your first jump in a while, our WordPress plugin PHP 8 compatibility guide covers the bigger breaking changes from 8.0 on, and managing PHP deprecation notices covers how to log them without showing them to visitors. For a sibling of the alias fix, see our utf8_decode() replacement guide. The full list lives in the PHP 8.6 deprecations RFC and the PHP 8.6 release notes.

FAQ

Is list() deprecated in PHP 8.6?

No. It was proposed in the same RFC, and the vote came out 23 yes, 23 no, 1 abstain. That is well short of two thirds, so list() stays.

Is the _() gettext alias deprecated?

No. That proposal failed by a wide margin. What passed is narrower: using _ as a constant name. Your _() calls are fine, though WordPress code should be using __() anyway.

Does WordPress 7.2 support PHP 8.6?

Core says yes. The 7.2 Beta 5 announcement says all known PHP 8.6 compatibility issues have been resolved, and the post-RC1 development source we checked is clean. Plugins and themes are your problem, and the same announcement says so.

Will my site break on PHP 8.6?

Not from the deprecations. They are notices. What can break a site is the stuff in the “still bite” section, a fatal error in an old plugin that was already fragile on 8.x, or a host that turns on display_errors. Test on staging and you will know.

Should I switch my host to PHP 8.6 today?

Not on production. A .0 release is where the edge cases show up, and WordPress 7.2 is not out until December 8. Run staging on 8.6 now, fix what the log shows, and move production once 8.6.1 or 8.6.2 is out and your plugins are clean.

When will these functions be removed?

The RFC targets PHP 9. PHP 9 has no release date. That gives you time, not permission to ignore it.

None of this breaks your site today. Update core, run the grep and the lint, and clear the log on staging before your host makes the switch for you.

Leave a Comment

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


Scroll to Top