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

WordPress Trac noreply at wordpress.org
Thu Aug 12 17:49:17 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-
                                            |  standards
--------------------------------------------+------------------------------

Comment (by SergeyBiryukov):

 In [changeset:"51606" 51606]:
 {{{
 #!CommitTicketReference repository="" revision="51606"
 Tests: Use correct comparison in `do_enclose()` tests.

 As per the PHP manual:
 > If the `component` parameter is omitted, an associative array is
 returned.
 > If the `component` parameter is specified, `parse_url()` returns a
 string (or an int, in the case of `PHP_URL_PORT`) instead of an array. If
 the requested component doesn't exist within the given URL, `null` will be
 returned.

 Reference: [https://www.php.net/manual/en/function.parse-
 url.php#refsect1-function.parse-url-returnvalues PHP Manual: parse_url():
 Return Values]

 In this case, `parse_url()` is called with the `PHP_URL_PATH` as
 `$component`, but the returned value is subsequently checked against
 `false`.

 In other words, this condition would previously always result in `true`
 and would lead to `null` potentially being passed to the PHP native
 `pathinfo()` function which expects a string.

 On PHP 8.1, this would result in a test failure with a `pathinfo():
 Passing null to parameter #1 ($path) of type string is deprecated` error.

 Reference: [https://www.php.net/manual/en/function.pathinfo.php PHP
 Manual: pathinfo()]

 Follow-up to [46175].

 Props jrf.
 See #53635.
 }}}

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


More information about the wp-trac mailing list