Core support for partial updates. see #10611.

git-svn-id: http://svn.automattic.com/wordpress/trunk@18225 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2011-06-10 05:47:44 +00:00
parent fa2d658ab7
commit 493ac83f33
4 changed files with 35 additions and 24 deletions

View File

@ -885,7 +885,21 @@ class Core_Upgrader extends WP_Upgrader {
$wp_dir = trailingslashit($wp_filesystem->abspath()); $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) ) if ( is_wp_error($download) )
return $download; return $download;

View File

@ -71,7 +71,7 @@ function list_core_update( $update ) {
} else { } else {
submit_button( $submit, 'button', 'upgrade', false ); submit_button( $submit, 'button', 'upgrade', false );
} }
echo '&nbsp;<a href="' . esc_url( $update->package ) . '" class="button">' . $download . '</a>&nbsp;'; echo '&nbsp;<a href="' . esc_url( $update->download ) . '" class="button">' . $download . '</a>&nbsp;';
} }
if ( 'en_US' != $update->locale ) if ( 'en_US' != $update->locale )
if ( !isset( $update->dismissed ) || !$update->dismissed ) if ( !isset( $update->dismissed ) || !$update->dismissed )

View File

@ -58,7 +58,7 @@ function wp_version_check() {
} }
$local_package = isset( $wp_local_package )? $wp_local_package : ''; $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( $options = array(
'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ), 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ),
@ -75,29 +75,26 @@ function wp_version_check() {
return false; return false;
$body = trim( wp_remote_retrieve_body( $response ) ); $body = trim( wp_remote_retrieve_body( $response ) );
$body = str_replace(array("\r\n", "\r"), "\n", $body); if ( ! $body = maybe_unserialize( $body ) )
$new_options = array(); return false;
foreach ( explode( "\n\n", $body ) as $entry ) { if ( ! isset( $body['offers'] ) )
$returns = explode("\n", $entry); return false;
$new_option = new stdClass(); $offers = $body['offers'];
$new_option->response = esc_attr( $returns[0] );
if ( isset( $returns[1] ) ) foreach ( $offers as &$offer ) {
$new_option->url = esc_url( $returns[1] ); foreach ( $offer as $offer_key => $value ) {
if ( isset( $returns[2] ) ) if ( 'packages' == $offer_key )
$new_option->package = esc_url( $returns[2] ); $offer['packages'] = (object) array_intersect_key( array_map( 'esc_url', $offer['packages'] ), array_fill_keys( array( 'full', 'no_content', 'new_bundled', 'partial' ), '' ) );
if ( isset( $returns[3] ) ) elseif ( 'download' == $offer_key )
$new_option->current = esc_attr( $returns[3] ); $offer['download'] = esc_url( $value );
if ( isset( $returns[4] ) ) else
$new_option->locale = esc_attr( $returns[4] ); $offer[ $offer_key ] = esc_html( $value );
if ( isset( $returns[5] ) ) }
$new_option->php_version = esc_attr( $returns[5] ); $offer = (object) array_intersect_key( $offer, array_fill_keys( array( 'response', 'download', 'locale', 'packages', 'current', 'php_version', 'mysql_version', 'new_bundled' ), '' ) );
if ( isset( $returns[6] ) )
$new_option->mysql_version = esc_attr( $returns[6] );
$new_options[] = $new_option;
} }
$updates = new stdClass(); $updates = new stdClass();
$updates->updates = $new_options; $updates->updates = $offers;
$updates->last_checked = time(); $updates->last_checked = time();
$updates->version_checked = $wp_version; $updates->version_checked = $wp_version;
set_site_transient( 'update_core', $updates); set_site_transient( 'update_core', $updates);

View File

@ -11,7 +11,7 @@ $wp_version = '3.2-beta2-18209';
* *
* @global int $wp_db_version * @global int $wp_db_version
*/ */
$wp_db_version = 17517; $wp_db_version = 18220;
/** /**
* Holds the TinyMCE version * Holds the TinyMCE version