diff --git a/src/wp-includes/Text/Diff.php b/src/wp-includes/Text/Diff.php index eee4e4f8ea531..b3c63afc5f859 100644 --- a/src/wp-includes/Text/Diff.php +++ b/src/wp-includes/Text/Diff.php @@ -276,7 +276,7 @@ function _check($from_lines, $to_lines) $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/tests/phpunit/tests/diff/Text_Diff_Check_Test.php b/tests/phpunit/tests/diff/Text_Diff_Check_Test.php new file mode 100644 index 0000000000000..dec8193ad0896 --- /dev/null +++ b/tests/phpunit/tests/diff/Text_Diff_Check_Test.php @@ -0,0 +1,37 @@ +assertTrue( $diff->_check( self::FILE_A, self::FILE_B ) ); + } +}