WordPress.org

Make WordPress Core


Ignore:
Timestamp:
06/10/2011 05:47:44 AM (10 years ago)
Author:
nacin
Message:

Core support for partial updates. see #10611.

File:
1 edited

Legend:

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

    r17928 r18225  
    5959
    6060    $local_package = isset( $wp_local_package )? $wp_local_package : '';
    61     $url = "http://api.wordpress.org/core/version-check/1.5/?version=$wp_version&php=$php_version&locale=$locale&mysql=$mysql_version&local_package=$local_package&blogs=$num_blogs&users={$user_count['total_users']}&multisite_enabled=$multisite_enabled";
     61    $url = "http://api.wordpress.org/core/version-check/1.6-beta/?version=$wp_version&php=$php_version&locale=$locale&mysql=$mysql_version&local_package=$local_package&blogs=$num_blogs&users={$user_count['total_users']}&multisite_enabled=$multisite_enabled";
    6262
    6363    $options = array(
     
    7676
    7777    $body = trim( wp_remote_retrieve_body( $response ) );
    78     $body = str_replace(array("\r\n", "\r"), "\n", $body);
    79     $new_options = array();
    80     foreach ( explode( "\n\n", $body ) as $entry ) {
    81         $returns = explode("\n", $entry);
    82         $new_option = new stdClass();
    83         $new_option->response = esc_attr( $returns[0] );
    84         if ( isset( $returns[1] ) )
    85             $new_option->url = esc_url( $returns[1] );
    86         if ( isset( $returns[2] ) )
    87             $new_option->package = esc_url( $returns[2] );
    88         if ( isset( $returns[3] ) )
    89             $new_option->current = esc_attr( $returns[3] );
    90         if ( isset( $returns[4] ) )
    91             $new_option->locale = esc_attr( $returns[4] );
    92         if ( isset( $returns[5] ) )
    93             $new_option->php_version = esc_attr( $returns[5] );
    94         if ( isset( $returns[6] ) )
    95             $new_option->mysql_version = esc_attr( $returns[6] );
    96         $new_options[] = $new_option;
     78    if ( ! $body = maybe_unserialize( $body ) )
     79        return false;
     80    if ( ! isset( $body['offers'] ) )
     81        return false;
     82    $offers = $body['offers'];
     83
     84    foreach ( $offers as &$offer ) {
     85        foreach ( $offer as $offer_key => $value ) {
     86            if ( 'packages' == $offer_key )
     87                $offer['packages'] = (object) array_intersect_key( array_map( 'esc_url', $offer['packages'] ), array_fill_keys( array( 'full', 'no_content', 'new_bundled', 'partial' ), '' ) );
     88            elseif ( 'download' == $offer_key )
     89                $offer['download'] = esc_url( $value );
     90            else
     91                $offer[ $offer_key ] = esc_html( $value );
     92        }
     93        $offer = (object) array_intersect_key( $offer, array_fill_keys( array( 'response', 'download', 'locale', 'packages', 'current', 'php_version', 'mysql_version', 'new_bundled' ), '' ) );
    9794    }
    9895
    9996    $updates = new stdClass();
    100     $updates->updates = $new_options;
     97    $updates->updates = $offers;
    10198    $updates->last_checked = time();
    10299    $updates->version_checked = $wp_version;
Note: See TracChangeset for help on using the changeset viewer.