[wp-trac] [WordPress Trac] #53635: PHP 8.1: various compatibility fixes
WordPress Trac
noreply at wordpress.org
Sun Aug 22 20:06:52 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 jrf):
I've just uploaded another patch - `53635-07-incorrect-default-value-for-
http_build_query.patch` - which is ready for commit.
Full patch description:
== PHP 8.1: WP_Sitemaps_Provider::get_sitemap_url(): fix deprecation
notice
The `WP_Sitemaps_Provider::get_sitemap_url()` method calls the PHP native
`http_build_query()` function, the second parameter of which is the
_optional_ `$numeric_prefix` parameter which expects a `string`.
A parameter being optional, however, does not automatically make it
nullable.
As of PHP 8.1, passing `null` to a non-nullable PHP native function will
generate a deprecation notice.
In this case, this function call yielded a `http_build_query(): Passing
null to parameter #2 ($numeric_prefix) of type string is deprecated`
notice.
Changing the `null` to an empty string fixes this without BC-break.
This change is already covered by tests as 14 of the existing tests
(targetting the sitemap functions) failed on these function calls when
running the tests on PHP 8.1.
Refs:
* https://www.php.net/manual/en/function.http-build-query.php
* https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg
--
Ticket URL: <https://core.trac.wordpress.org/ticket/53635#comment:67>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list