From 4ab4b38ecde079c37d6a73369ad3a5844913d9c0 Mon Sep 17 00:00:00 2001 From: hellofromTonya Date: Thu, 19 Sep 2024 20:22:15 +0000 Subject: [PATCH] External Libraries: Skip instanceof check when null in Text_Diff::_check(). On the first `foreach` loop in Text_Diff::_check()`, `$prevtype` is `null`. As `instanceof` requires the class name term to be an object or string, a fatal error is thrown: >Fatal error: Uncaught Error: Class name must be a valid object or a string on line 279 This change: * Adds a simple test for the `Text_Diff::_check()` method, which is how the bug was discovered as the test could never pass with the code as-is. * Adds a defensive guard to protect against the fatal. It checks if `$prevtype` is not `null` as a pre-condition to for checking the instance. This bugfix also resolves the failing test. Follow-up to [49194], [7747]. Props jrf, hellofromTonya. See #62083. Built from https://develop.svn.wordpress.org/trunk@59070 git-svn-id: http://core.svn.wordpress.org/trunk@58466 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/Text/Diff.php | 2 +- wp-includes/version.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-includes/Text/Diff.php b/wp-includes/Text/Diff.php index eee4e4f8ea..b3c63afc5f 100644 --- a/wp-includes/Text/Diff.php +++ b/wp-includes/Text/Diff.php @@ -276,7 +276,7 @@ class Text_Diff { $prevtype = null; foreach ($this->_edits as $edit) { - if ($edit instanceof $prevtype) { + if ($prevtype !== null && $edit instanceof $prevtype) { trigger_error("Edit sequence is non-optimal", E_USER_ERROR); } $prevtype = get_class($edit); diff --git a/wp-includes/version.php b/wp-includes/version.php index 6a9c543157..114c76a8d8 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.7-alpha-59069'; +$wp_version = '6.7-alpha-59070'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.