Code Modernization: Pass correct default value to http_build_query() in get_core_checksums() and wp_version_check().

The `get_core_checksums()` and `wp_version_check()` functions call the PHP native `http_build_query()` function, the second parameter of which is the ''optional'' `$numeric_prefix` parameter which expects a non-nullable `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.

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 [18697], [25540].

Props bjorsch, kraftbj, hellofromTonya, jrf.
See #54229.
Built from https://develop.svn.wordpress.org/trunk@52019


git-svn-id: http://core.svn.wordpress.org/trunk@51611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
hellofromTonya 2021-11-05 12:18:58 +00:00
parent 500da91f70
commit b9d15392bf
3 changed files with 3 additions and 3 deletions

View File

@ -120,7 +120,7 @@ function find_core_auto_update() {
* @return array|false An array of checksums on success, false on failure. * @return array|false An array of checksums on success, false on failure.
*/ */
function get_core_checksums( $version, $locale ) { function get_core_checksums( $version, $locale ) {
$http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), null, '&' ); $http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), '', '&' );
$url = $http_url; $url = $http_url;
$ssl = wp_http_supports( array( 'ssl' ) ); $ssl = wp_http_supports( array( 'ssl' ) );

View File

@ -143,7 +143,7 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) {
$query['channel'] = WP_AUTO_UPDATE_CORE; $query['channel'] = WP_AUTO_UPDATE_CORE;
} }
$url = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, null, '&' ); $url = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, '', '&' );
$http_url = $url; $http_url = $url;
$ssl = wp_http_supports( array( 'ssl' ) ); $ssl = wp_http_supports( array( 'ssl' ) );

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.9-alpha-52018'; $wp_version = '5.9-alpha-52019';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.