WordPress.org

Make WordPress Core

Changeset 18225


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

Core support for partial updates. see #10611.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-upgrader.php

    r18084 r18225  
    886886        $wp_dir = trailingslashit($wp_filesystem->abspath());
    887887
    888         $download = $this->download_package( $current->package );
     888        // If partial update is returned from the API, use that, unless we're doing a reinstall.
     889        // If we cross the new_bundled version number, then use the new_bundled zip.
     890        // Don't though if the constant is set to skip bundled items.
     891        // If the API returns a no_content zip, go with it. Finally, default to the full zip.
     892        if ( $current->packages->partial && 'reinstall' != $current->response )
     893            $to_download = 'partial';
     894        elseif ( $current->packages->new_bundled && version_compare( $wp_version, $current->new_bundled, '<' )
     895            && ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) )
     896            $to_download = 'new_bundled';
     897        elseif ( $current->packages->no_content )
     898            $to_download = 'no_content';
     899        else
     900            $to_download = 'full';
     901
     902        $download = $this->download_package( $current->packages->$to_download );
    889903        if ( is_wp_error($download) )
    890904            return $download;
  • trunk/wp-admin/update-core.php

    r18224 r18225  
    7272            submit_button( $submit, 'button', 'upgrade', false );
    7373        }
    74         echo '&nbsp;<a href="' . esc_url( $update->package ) . '" class="button">' . $download . '</a>&nbsp;';
     74        echo '&nbsp;<a href="' . esc_url( $update->download ) . '" class="button">' . $download . '</a>&nbsp;';
    7575    }
    7676    if ( 'en_US' != $update->locale )
  • 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;
  • trunk/wp-includes/version.php

    r18209 r18225  
    1212 * @global int $wp_db_version
    1313 */
    14 $wp_db_version = 17517;
     14$wp_db_version = 18220;
    1515
    1616/**
Note: See TracChangeset for help on using the changeset viewer.