WordPress.org

Make WordPress Core

Changeset 52019


Ignore:
Timestamp:
11/05/2021 12:17:32 PM (2 months ago)
Author:
hellofromTonya
Message:

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:

Follow-up to [18697], [25540].

Props bjorsch, kraftbj, hellofromTonya, jrf.
See #54229.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/update.php

    r51733 r52019  
    121121 */
    122122function get_core_checksums( $version, $locale ) {
    123     $http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), null, '&' );
     123    $http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), '', '&' );
    124124    $url      = $http_url;
    125125
  • trunk/src/wp-includes/update.php

    r51657 r52019  
    144144    }
    145145
    146     $url      = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, null, '&' );
     146    $url      = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, '', '&' );
    147147    $http_url = $url;
    148148    $ssl      = wp_http_supports( array( 'ssl' ) );
Note: See TracChangeset for help on using the changeset viewer.