[wp-trac] [WordPress Trac] #62083: Text_Diff::_check() throws a fatal error when $prevtype is null.
WordPress Trac
noreply at wordpress.org
Thu Sep 19 20:15:25 UTC 2024
#62083: Text_Diff::_check() throws a fatal error when $prevtype is null.
--------------------------------+----------------------
Reporter: hellofromTonya | Owner: (none)
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 6.7
Component: External Libraries | Version: 5.6
Severity: normal | Keywords:
Focuses: |
--------------------------------+----------------------
`Text_Diff::_check()` will throw a fatal error when `$prevtype` is null.
>Fatal error: Uncaught Error: Class name must be a valid object or a
string
`instanceof` requires the class name's term to be an object or string.
See it in action here https://3v4l.org/rQ0s4#veol.
Looking at the existing code (using
[https://core.trac.wordpress.org/browser/trunk/src/wp-
includes/Text/Diff.php?annotate=blame#L279 the 6.6.2 tagged version as its
the latest release as of this ticket]),
{{{
$prevtype = null;
foreach ($this->_edits as $edit) {
if ($edit instanceof $prevtype) {
trigger_error("Edit sequence is non-optimal", E_USER_ERROR);
}
$prevtype = get_class($edit);
}
}}}
this means `$prevtype` must be an object or string. On the first loop,
`$prevtype` is `null`.
For contextual history, [49194] changed from `get_class()` to
`instanceof`.
Reference:
* https://www.php.net/manual/en/language.operators.type.php
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62083>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list