Index: src/wp-includes/update.php
===================================================================
--- src/wp-includes/update.php	(revision 42461)
+++ src/wp-includes/update.php	(working copy)
@@ -161,31 +161,32 @@ function wp_version_check( $extra_stats 
 		);
 		$response = wp_remote_post( $http_url, $options );
 	}
 
 	if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
 		return;
 	}
 
 	$body = trim( wp_remote_retrieve_body( $response ) );
 	$body = json_decode( $body, true );
 
 	if ( ! is_array( $body ) || ! isset( $body['offers'] ) ) {
 		return;
 	}
 
-	$offers = $body['offers'];
+	$offers          = $body['offers'];
+	$has_auto_update = false;
 
 	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', 'rollback' ), '' )
 				);
 			} elseif ( 'download' == $offer_key ) {
 				$offer['download'] = esc_url( $value );
 			} else {
 				$offer[ $offer_key ] = esc_html( $value );
 			}
 		}
 		$offer = (object) array_intersect_key(
@@ -195,54 +196,63 @@ function wp_version_check( $extra_stats 
 					'download',
 					'locale',
 					'packages',
 					'current',
 					'version',
 					'php_version',
 					'mysql_version',
 					'new_bundled',
 					'partial_version',
 					'notify_email',
 					'support_email',
 					'new_files',
 				), ''
 			)
 		);
+
+		if ( 'autoupdate' == $offer->response ) {
+			$has_auto_update = true;
+		}
 	}
 
 	$updates                  = new stdClass();
 	$updates->updates         = $offers;
 	$updates->last_checked    = time();
 	$updates->version_checked = $wp_version;
 
 	if ( isset( $body['translations'] ) ) {
 		$updates->translations = $body['translations'];
 	}
 
 	set_site_transient( 'update_core', $updates );
 
 	if ( ! empty( $body['ttl'] ) ) {
 		$ttl = (int) $body['ttl'];
 		if ( $ttl && ( time() + $ttl < wp_next_scheduled( 'wp_version_check' ) ) ) {
 			// Queue an event to re-run the update check in $ttl seconds.
 			wp_schedule_single_event( time() + $ttl, 'wp_version_check' );
 		}
 	}
 
 	// Trigger background updates if running non-interactively, and we weren't called from the update handler.
-	if ( $doing_cron && ! doing_action( 'wp_maybe_auto_update' ) ) {
-		do_action( 'wp_maybe_auto_update' );
+	if ( $doing_cron && $has_auto_update && ! doing_action( 'wp_maybe_auto_update' ) ) {
+		include_once( ABSPATH . '/wp-admin/includes/update.php' );
+
+		// Only trigger background updates if an acceptable autoupdate is on offer, avoids needless extra API calls.
+		if ( find_core_auto_update() ) {
+			do_action( 'wp_maybe_auto_update' );
+		}
 	}
 }
 
 /**
  * Check plugin versions against the latest versions hosted on WordPress.org.
  *
  * The WordPress version, PHP version, and Locale is sent along with a list of
  * all plugins installed. Checks against the WordPress server at
  * api.wordpress.org. Will only check if WordPress isn't installing.
  *
  * @since 2.3.0
  * @global string $wp_version Used to notify the WordPress version.
  *
  * @param array $extra_stats Extra statistics to report to the WordPress.org API.
  */
@@ -275,31 +285,31 @@ function wp_update_plugins( $extra_stats
 
 	// Check for update on a different schedule, depending on the page.
 	switch ( current_filter() ) {
 		case 'upgrader_process_complete':
 			$timeout = 0;
 			break;
 		case 'load-update-core.php':
 			$timeout = MINUTE_IN_SECONDS;
 			break;
 		case 'load-plugins.php':
 		case 'load-update.php':
 			$timeout = HOUR_IN_SECONDS;
 			break;
 		default:
 			if ( $doing_cron ) {
-				$timeout = 0;
+				$timeout = 2 * HOUR_IN_SECONDS;
 			} else {
 				$timeout = 12 * HOUR_IN_SECONDS;
 			}
 	}
 
 	$time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked );
 
 	if ( $time_not_changed && ! $extra_stats ) {
 		$plugin_changed = false;
 		foreach ( $plugins as $file => $p ) {
 			$new_option->checked[ $file ] = $p['Version'];
 
 			if ( ! isset( $current->checked[ $file ] ) || strval( $current->checked[ $file ] ) !== strval( $p['Version'] ) ) {
 				$plugin_changed = true;
 			}
@@ -462,31 +472,35 @@ function wp_update_themes( $extra_stats 
 	$doing_cron = wp_doing_cron();
 
 	// Check for update on a different schedule, depending on the page.
 	switch ( current_filter() ) {
 		case 'upgrader_process_complete':
 			$timeout = 0;
 			break;
 		case 'load-update-core.php':
 			$timeout = MINUTE_IN_SECONDS;
 			break;
 		case 'load-themes.php':
 		case 'load-update.php':
 			$timeout = HOUR_IN_SECONDS;
 			break;
 		default:
-			$timeout = $doing_cron ? 0 : 12 * HOUR_IN_SECONDS;
+			if ( $doing_cron ) {
+				$timeout = 2 * HOUR_IN_SECONDS;
+			} else {
+				$timeout = 12 * HOUR_IN_SECONDS;
+			}
 	}
 
 	$time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time() - $last_update->last_checked );
 
 	if ( $time_not_changed && ! $extra_stats ) {
 		$theme_changed = false;
 		foreach ( $checked as $slug => $v ) {
 			if ( ! isset( $last_update->checked[ $slug ] ) || strval( $last_update->checked[ $slug ] ) !== strval( $v ) ) {
 				$theme_changed = true;
 			}
 		}
 
 		if ( isset( $last_update->response ) && is_array( $last_update->response ) ) {
 			foreach ( $last_update->response as $slug => $update_details ) {
 				if ( ! isset( $checked[ $slug ] ) ) {
