Skip to content

Commit

Permalink
Code Modernization: Avoid passing null to parameter 2 of `http_build_…
Browse files Browse the repository at this point in the history
…query()`

This fixes the "Deprecated: http_build_query(): Passing null to parameter WordPress#2 ($numeric_prefix) of type string is deprecated" warning on PHP 8.1.

PHP has started requiring that built-in method arguments that are not explicitly declared as nullable may no longer be passed null. The correct value for the `$numeric_prefix` parameter to `http_build_query()` is an empty string.

Trac ticket: https://core.trac.wordpress.org/ticket/53635
  • Loading branch information
anomiex committed Nov 2, 2021
1 parent df8a2b4 commit 2464478
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/wp-admin/includes/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function find_core_auto_update() {
* @return array|false An array of checksums on success, false on failure.
*/
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;

$ssl = wp_http_supports( array( 'ssl' ) );
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/Requests/Transport/cURL.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ protected function setup_handle($url, $headers, $data, $options) {
$data = '';
}
elseif (!is_string($data)) {
$data = http_build_query($data, null, '&');
$data = http_build_query($data, '', '&');
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) {
$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;
$ssl = wp_http_supports( array( 'ssl' ) );

Expand Down

0 comments on commit 2464478

Please sign in to comment.