WordPress/wp-includes/Text
hellofromTonya 4ab4b38ecd 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
2024-09-19 20:22:15 +00:00
..
Diff
Diff.php External Libraries: Skip instanceof check when null in Text_Diff::_check(). 2024-09-19 20:22:15 +00:00