[wp-trac] [WordPress Trac] #53635: PHP 8.1: various compatibility fixes

WordPress Trac noreply at wordpress.org
Fri Sep 10 15:02:22 UTC 2021


#53635: PHP 8.1: various compatibility fixes
-------------------------------------------------+-------------------------
 Reporter:  SergeyBiryukov                       |       Owner:
                                                 |  hellofromTonya
     Type:  task (blessed)                       |      Status:  accepted
 Priority:  normal                               |   Milestone:  5.9
Component:  General                              |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  php81 has-patch has-unit-tests       |     Focuses:  coding-
  commit                                         |  standards
-------------------------------------------------+-------------------------

Comment (by hellofromTonya):

 In [changeset:"51796" 51796]:
 {{{
 #!CommitTicketReference repository="" revision="51796"
 Code Modernization: Fix null to non-nullable deprecation in
 `term_exists()`.

 The `term_exists()` function expects a string or an integer for the
 `$term` parameter. It validates for integer, but not for string or `null`.

 One of the pre-existing test cases, passed `null` to the function, leading
 to a `trim(): Passing null to parameter #1 ($string) of type string is
 deprecated` notice on PHP 8.1.

 Fixed now by doing a cursory check on the variable at the start of the
 function and bowing out early in case the `$term` is `null`.

 The issue was discovered via and is already covered by the
 `Tests_TermExists::test_term_exists_unknown()` test method.

 Follow-up to [15220]. [38716].

 Props jrf, hellofromTonya.
 See #53635.
 }}}

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


More information about the wp-trac mailing list