From b2c50ddc5697b63d6f999f4985f805028af09d10 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Fri, 10 Jun 2011 05:47:44 +0000 Subject: [PATCH] Core support for partial updates. see #10611. git-svn-id: https://develop.svn.wordpress.org/trunk@18225 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/class-wp-upgrader.php | 16 +++++++++- wp-admin/update-core.php | 2 +- wp-includes/update.php | 39 ++++++++++++------------- wp-includes/version.php | 2 +- 4 files changed, 35 insertions(+), 24 deletions(-) diff --git a/wp-admin/includes/class-wp-upgrader.php b/wp-admin/includes/class-wp-upgrader.php index 4270d090da..04819fbf2d 100644 --- a/wp-admin/includes/class-wp-upgrader.php +++ b/wp-admin/includes/class-wp-upgrader.php @@ -885,7 +885,21 @@ class Core_Upgrader extends WP_Upgrader { $wp_dir = trailingslashit($wp_filesystem->abspath()); - $download = $this->download_package( $current->package ); + // If partial update is returned from the API, use that, unless we're doing a reinstall. + // If we cross the new_bundled version number, then use the new_bundled zip. + // Don't though if the constant is set to skip bundled items. + // If the API returns a no_content zip, go with it. Finally, default to the full zip. + if ( $current->packages->partial && 'reinstall' != $current->response ) + $to_download = 'partial'; + elseif ( $current->packages->new_bundled && version_compare( $wp_version, $current->new_bundled, '<' ) + && ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) + $to_download = 'new_bundled'; + elseif ( $current->packages->no_content ) + $to_download = 'no_content'; + else + $to_download = 'full'; + + $download = $this->download_package( $current->packages->$to_download ); if ( is_wp_error($download) ) return $download; diff --git a/wp-admin/update-core.php b/wp-admin/update-core.php index d7f7831bc4..85c70a419d 100644 --- a/wp-admin/update-core.php +++ b/wp-admin/update-core.php @@ -71,7 +71,7 @@ function list_core_update( $update ) { } else { submit_button( $submit, 'button', 'upgrade', false ); } - echo ' ' . $download . ' '; + echo ' ' . $download . ' '; } if ( 'en_US' != $update->locale ) if ( !isset( $update->dismissed ) || !$update->dismissed ) diff --git a/wp-includes/update.php b/wp-includes/update.php index 4d473aed72..26ea4f8938 100644 --- a/wp-includes/update.php +++ b/wp-includes/update.php @@ -58,7 +58,7 @@ function wp_version_check() { } $local_package = isset( $wp_local_package )? $wp_local_package : ''; - $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"; + $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"; $options = array( 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ), @@ -75,29 +75,26 @@ function wp_version_check() { return false; $body = trim( wp_remote_retrieve_body( $response ) ); - $body = str_replace(array("\r\n", "\r"), "\n", $body); - $new_options = array(); - foreach ( explode( "\n\n", $body ) as $entry ) { - $returns = explode("\n", $entry); - $new_option = new stdClass(); - $new_option->response = esc_attr( $returns[0] ); - if ( isset( $returns[1] ) ) - $new_option->url = esc_url( $returns[1] ); - if ( isset( $returns[2] ) ) - $new_option->package = esc_url( $returns[2] ); - if ( isset( $returns[3] ) ) - $new_option->current = esc_attr( $returns[3] ); - if ( isset( $returns[4] ) ) - $new_option->locale = esc_attr( $returns[4] ); - if ( isset( $returns[5] ) ) - $new_option->php_version = esc_attr( $returns[5] ); - if ( isset( $returns[6] ) ) - $new_option->mysql_version = esc_attr( $returns[6] ); - $new_options[] = $new_option; + if ( ! $body = maybe_unserialize( $body ) ) + return false; + if ( ! isset( $body['offers'] ) ) + return false; + $offers = $body['offers']; + + foreach ( $offers as &$offer ) { + foreach ( $offer as $offer_key => $value ) { + if ( 'packages' == $offer_key ) + $offer['packages'] = (object) array_intersect_key( array_map( 'esc_url', $offer['packages'] ), array_fill_keys( array( 'full', 'no_content', 'new_bundled', 'partial' ), '' ) ); + elseif ( 'download' == $offer_key ) + $offer['download'] = esc_url( $value ); + else + $offer[ $offer_key ] = esc_html( $value ); + } + $offer = (object) array_intersect_key( $offer, array_fill_keys( array( 'response', 'download', 'locale', 'packages', 'current', 'php_version', 'mysql_version', 'new_bundled' ), '' ) ); } $updates = new stdClass(); - $updates->updates = $new_options; + $updates->updates = $offers; $updates->last_checked = time(); $updates->version_checked = $wp_version; set_site_transient( 'update_core', $updates); diff --git a/wp-includes/version.php b/wp-includes/version.php index 99d3db99cd..639f897f3e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -11,7 +11,7 @@ $wp_version = '3.2-beta2-18209'; * * @global int $wp_db_version */ -$wp_db_version = 17517; +$wp_db_version = 18220; /** * Holds the TinyMCE version