Commit 8ae6f8561c for wordpress.org
commit 8ae6f8561c523277dbdd446134d715b41744b60f
Author: peterwilsoncc <peterwilsoncc@git.wordpress.org>
Date: Fri Nov 6 02:19:55 2026 +0000
General: Replace `is_a()` conditions with `instanceOf` for PHP 8.6 compat.
PHP 8.6 deprecates passing class names as strings to `is_a()`, for example `is_a( $post, 'WP_Post' )`. This replaces the pattern with their equivalent `instanceof` conditions within the adopted IXR and Text packages.
Introduces tests to cover the code paths to demonstrate the tests fail in PHP 8.6.
Props dhrupo, westonruter.
Fixes #66418.
Built from https://develop.svn.wordpress.org/trunk@65303
git-svn-id: http://core.svn.wordpress.org/trunk@64445 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/IXR/class-IXR-introspectionserver.php b/wp-includes/IXR/class-IXR-introspectionserver.php
index afb05b0e0d..0be5d319d1 100644
--- a/wp-includes/IXR/class-IXR-introspectionserver.php
+++ b/wp-includes/IXR/class-IXR-introspectionserver.php
@@ -114,7 +114,7 @@ class IXR_IntrospectionServer extends IXR_Server
break;
case 'date':
case 'dateTime.iso8601':
- if (!is_a($arg, 'IXR_Date')) {
+ if (!($arg instanceof IXR_Date)) {
$ok = false;
}
break;
diff --git a/wp-includes/IXR/class-IXR-server.php b/wp-includes/IXR/class-IXR-server.php
index e11f40fbe7..1019718512 100644
--- a/wp-includes/IXR/class-IXR-server.php
+++ b/wp-includes/IXR/class-IXR-server.php
@@ -59,7 +59,7 @@ class IXR_Server
$result = $this->call($this->message->methodName, $this->message->params);
// Is the result an error?
- if (is_a($result, 'IXR_Error')) {
+ if ($result instanceof IXR_Error) {
$this->error($result);
}
@@ -234,7 +234,7 @@ EOD;
} else {
$result = $this->call($method, $params);
}
- if (is_a($result, 'IXR_Error')) {
+ if ($result instanceof IXR_Error) {
$return[] = array(
'faultCode' => $result->code,
'faultString' => $result->message
diff --git a/wp-includes/IXR/class-IXR-value.php b/wp-includes/IXR/class-IXR-value.php
index 850f318f2c..fcbb64012f 100644
--- a/wp-includes/IXR/class-IXR-value.php
+++ b/wp-includes/IXR/class-IXR-value.php
@@ -52,10 +52,10 @@ class IXR_Value {
}
// Deal with IXR object types base64 and date
- if (is_object($this->data) && is_a($this->data, 'IXR_Date')) {
+ if ($this->data instanceof IXR_Date) {
return 'date';
}
- if (is_object($this->data) && is_a($this->data, 'IXR_Base64')) {
+ if ($this->data instanceof IXR_Base64) {
return 'base64';
}
diff --git a/wp-includes/Text/Diff.php b/wp-includes/Text/Diff.php
index a7a79e5080..47b90cdb56 100644
--- a/wp-includes/Text/Diff.php
+++ b/wp-includes/Text/Diff.php
@@ -81,8 +81,8 @@ class Text_Diff {
{
$count = 0;
foreach ($this->_edits as $edit) {
- if (is_a($edit, 'Text_Diff_Op_add') ||
- is_a($edit, 'Text_Diff_Op_change')) {
+ if ($edit instanceof Text_Diff_Op_add ||
+ $edit instanceof Text_Diff_Op_change) {
$count += $edit->nfinal();
}
}
@@ -100,8 +100,8 @@ class Text_Diff {
{
$count = 0;
foreach ($this->_edits as $edit) {
- if (is_a($edit, 'Text_Diff_Op_delete') ||
- is_a($edit, 'Text_Diff_Op_change')) {
+ if ($edit instanceof Text_Diff_Op_delete ||
+ $edit instanceof Text_Diff_Op_change) {
$count += $edit->norig();
}
}
@@ -144,7 +144,7 @@ class Text_Diff {
function isEmpty()
{
foreach ($this->_edits as $edit) {
- if (!is_a($edit, 'Text_Diff_Op_copy')) {
+ if (!($edit instanceof Text_Diff_Op_copy)) {
return false;
}
}
@@ -162,7 +162,7 @@ class Text_Diff {
{
$lcs = 0;
foreach ($this->_edits as $edit) {
- if (is_a($edit, 'Text_Diff_Op_copy')) {
+ if ($edit instanceof Text_Diff_Op_copy) {
$lcs += count($edit->orig);
}
}
diff --git a/wp-includes/Text/Diff/Renderer.php b/wp-includes/Text/Diff/Renderer.php
index 2417670aef..ccaaa62fbf 100644
--- a/wp-includes/Text/Diff/Renderer.php
+++ b/wp-includes/Text/Diff/Renderer.php
@@ -90,7 +90,7 @@ class Text_Diff_Renderer {
/* If these are unchanged (copied) lines, and we want to keep
* leading or trailing context lines, extract them from the copy
* block. */
- if (is_a($edit, 'Text_Diff_Op_copy')) {
+ if ($edit instanceof Text_Diff_Op_copy) {
/* Do we have any diff blocks yet? */
if (is_array($block)) {
/* How many lines to keep as context from the copy
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 61d89a1495..b92ea5aa39 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-beta4-65294';
+$wp_version = '7.2-beta4-65303';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.