From e53ffbaf955beb449c9ecd22c3ba3d9a25030553 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 23 Aug 2021 11:44:01 +0000 Subject: [PATCH] Code Modernization: Pass correct default value to `http_build_query()` in `WP_Sitemaps_Provider::get_sitemap_url()`. 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 a backward compatibility break. This change is already covered by tests as 14 of the existing tests failed on these function calls when running the tests on PHP 8.1. References: * [https://www.php.net/manual/en/function.http-build-query.php PHP Manual: http_build_query()] * [https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg PHP RFC: Deprecate passing null to non-nullable arguments of internal functions] Follow-up to [48470]. Props jrf. See #53635. Built from https://develop.svn.wordpress.org/trunk@51652 git-svn-id: http://core.svn.wordpress.org/trunk@51258 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/sitemaps/class-wp-sitemaps-provider.php | 2 +- wp-includes/version.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-includes/sitemaps/class-wp-sitemaps-provider.php b/wp-includes/sitemaps/class-wp-sitemaps-provider.php index 3440f62b34..e77681d721 100644 --- a/wp-includes/sitemaps/class-wp-sitemaps-provider.php +++ b/wp-includes/sitemaps/class-wp-sitemaps-provider.php @@ -160,7 +160,7 @@ abstract class WP_Sitemaps_Provider { ); if ( ! $wp_rewrite->using_permalinks() ) { - $basename = '/?' . http_build_query( $params, null, '&' ); + $basename = '/?' . http_build_query( $params, '', '&' ); } return home_url( $basename ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 68c87cfe7f..b670481167 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-alpha-51651'; +$wp_version = '5.9-alpha-51652'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.