[wp-trac] [WordPress Trac] #54730: PHP 8.x: various compatibility fixes for WordPress 6.0

WordPress Trac noreply at wordpress.org
Fri Feb 25 13:46:37 UTC 2022

#54730: PHP 8.x: various compatibility fixes for WordPress 6.0
 Reporter:  hellofromTonya                       |       Owner:  (none)
     Type:  task (blessed)                       |      Status:  new
 Priority:  normal                               |   Milestone:  6.0
Component:  General                              |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  php8 php81 has-patch has-unit-tests  |     Focuses:  coding-
                                                 |  standards

Comment (by SergeyBiryukov):

 In [changeset:"52799" 52799]:
 #!CommitTicketReference repository="" revision="52799"
 Code Modernization: Check the return type of `wp_parse_url()` in

 As per the PHP manual:
 > If the `component` parameter is omitted, an associative array is
 > 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

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

 In PHP 8.1, if the home URL does not have a "host" component, it would
 lead to a `substr(): Passing null to parameter #1 ($string) of type string
 is deprecated` notice.

 Changing the logic around and adding validation for the return type value
 of `wp_parse_url()` prevents that.

 Follow-up to [48601], [51606], [51622], [51626], [51629], [51630].

 Props dennisatyoast, jrf.
 See #54730.

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

More information about the wp-trac mailing list