[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:20:47 UTC 2024


#62083: Text_Diff::_check() throws a fatal error when $prevtype is null.
---------------------------------------------+-----------------------------
 Reporter:  hellofromTonya                   |       Owner:  hellofromTonya
     Type:  defect (bug)                     |      Status:  reviewing
 Priority:  normal                           |   Milestone:  6.7
Component:  External Libraries               |     Version:  5.6
 Severity:  normal                           |  Resolution:
 Keywords:  has-patch has-unit-tests commit  |     Focuses:
---------------------------------------------+-----------------------------

Comment (by hellofromTonya):

 In [changeset:"59070" 59070]:
 {{{
 #!CommitTicketReference repository="" revision="59070"
 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.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/62083#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list