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

WordPress Trac noreply at wordpress.org
Wed Aug 11 01:37:09 UTC 2021

#53635: PHP 8.1: various compatibility fixes
 Reporter:  SergeyBiryukov  |       Owner:  (none)
     Type:  task (blessed)  |      Status:  new
 Priority:  normal          |   Milestone:  5.9
Component:  General         |     Version:
 Severity:  normal          |  Resolution:
 Keywords:  php81           |     Focuses:  coding-standards

Comment (by jrf):

 The patch I've just uploaded - `53635-05-null-to-non-nullable-in-
 testcode.patch` - is a test code only patch and ready for commit.

 Fixes two tests which were erroring out.

 Commit details:

 == PHP 8.1: Tests_Functions_DoEnclose: fix bug in test

 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

 Ref: https://www.php.net/manual/en/function.parse-

 In this case, `parse_url()` is called with the `PHP_URL_PATH` as
 `$component`, but the returned value is subsequently checked against
 In other words, this condition would previously always result `true` and
 would lead to `null`, potentially, being passed to the PHP native
 `pathinfo()` function which expects a string.

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

 Ref: https://www.php.net/manual/en/function.pathinfo.php

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

More information about the wp-trac mailing list