[wp-trac] [WordPress Trac] #53635: PHP 8.1: various compatibility fixes
WordPress Trac
noreply at wordpress.org
Tue Aug 17 21:56:55 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 SergeyBiryukov):
In [changeset:"51629" 51629]:
{{{
#!CommitTicketReference repository="" revision="51629"
Code Modernization: Check the return type of `parse_url()` on Plugin/Theme
Editor screens.
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]
While it is probably unlikely that someone would have a direct link to the
plugin/theme editor on their home page or even on someone else's homepage,
it is entirely possible for the referrer URL to not have a "path"
component.
In PHP 8.1, this would lead to a `basename(): 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 `parse_url()` prevents that.
Follow-up to [51606], [51622], [51626].
Props jrf, hellofromTonya, SergeyBiryukov.
See #53635.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/53635#comment:47>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list