Make WordPress Core

Ticket #47528: 47528-get-core-checksums-mod.diff

File 47528-get-core-checksums-mod.diff, 2.8 KB (added by SirLouen, 8 months ago)
  • src/wp-admin/includes/update.php

    diff --git src/wp-admin/includes/update.php src/wp-admin/includes/update.php
    index 33325236e3..e67f7c068b 100644
    function find_core_auto_update() { 
    129129 * @return array|false An array of checksums on success, false on failure.
    130130 */
    131131function get_core_checksums( $version, $locale ) {
    132         $http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), '', '&' );
    133         $url      = $http_url;
     132        $checksum_file = ABSPATH . 'wp-content/uploads/checksum/checksum.md5';
    134133
    135         $ssl = wp_http_supports( array( 'ssl' ) );
    136 
    137         if ( $ssl ) {
    138                 $url = set_url_scheme( $url, 'https' );
     134        if ( ! file_exists( $checksum_file ) ) {
     135                return false;
    139136        }
     137        $file_contents = file_get_contents( $checksum_file );
    140138
    141         $options = array(
    142                 'timeout' => wp_doing_cron() ? 30 : 3,
    143         );
     139        if ( false === $file_contents ) {
     140                return false;
     141        }
    144142
    145         $response = wp_remote_get( $url, $options );
    146 
    147         if ( $ssl && is_wp_error( $response ) ) {
    148                 wp_trigger_error(
    149                         __FUNCTION__,
    150                         sprintf(
    151                                 /* translators: %s: Support forums URL. */
    152                                 __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
    153                                 __( 'https://wordpress.org/support/forums/' )
    154                         ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ),
    155                         headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE
    156                 );
     143        $lines     = explode( "\n", trim( $file_contents ) );
     144        $checksums = array();
    157145
    158                 $response = wp_remote_get( $http_url, $options );
    159         }
     146        foreach ( $lines as $line ) {
     147                $line = trim( $line );
    160148
    161         if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
    162                 return false;
    163         }
     149                if ( empty( $line ) ) {
     150                        continue;
     151                }
    164152
    165         $body = trim( wp_remote_retrieve_body( $response ) );
    166         $body = json_decode( $body, true );
     153                $parts = preg_split( '/\s+/', $line, 2 );
    167154
    168         if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) ) {
    169                 return false;
     155                if ( count( $parts ) === 2 ) {
     156                        $hash                   = $parts[0];
     157                        $filename               = $parts[1];
     158                        $filename               = ltrim( $filename, './' );
     159                        $checksums[ $filename ] = $hash;
     160                }
    170161        }
    171162
    172         return $body['checksums'];
     163        return $checksums;
    173164}
    174165
    175166/**
  • src/wp-includes/version.php

    diff --git src/wp-includes/version.php src/wp-includes/version.php
    index 324ee3279f..e3f3195bde 100644
     
    1616 *
    1717 * @global string $wp_version
    1818 */
    19 $wp_version = '6.9-alpha-60093-src';
     19$wp_version = '6.8.2';
    2020
    2121/**
    2222 * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.