Use transient for update_core, update_plugins, update_themes. see #9048
git-svn-id: http://svn.automattic.com/wordpress/trunk@10515 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0d258926e7
commit
7aec230e33
|
@ -254,7 +254,7 @@ function update_core($from, $to) {
|
||||||
$wp_filesystem->delete($from, true);
|
$wp_filesystem->delete($from, true);
|
||||||
|
|
||||||
// Force refresh of update information
|
// Force refresh of update information
|
||||||
delete_option('update_core');
|
delete_transient('update_core');
|
||||||
|
|
||||||
// Remove maintenance file, we're done.
|
// Remove maintenance file, we're done.
|
||||||
$wp_filesystem->delete($maintenance_file);
|
$wp_filesystem->delete($maintenance_file);
|
||||||
|
|
|
@ -33,7 +33,7 @@ function get_core_updates( $options = array() ) {
|
||||||
$options = array_merge( array('available' => true, 'dismissed' => false ), $options );
|
$options = array_merge( array('available' => true, 'dismissed' => false ), $options );
|
||||||
$dismissed = get_option( 'dismissed_update_core' );
|
$dismissed = get_option( 'dismissed_update_core' );
|
||||||
if ( !is_array( $dismissed ) ) $dismissed = array();
|
if ( !is_array( $dismissed ) ) $dismissed = array();
|
||||||
$from_api = get_option( 'update_core' );
|
$from_api = get_transient( 'update_core' );
|
||||||
if ( empty($from_api) )
|
if ( empty($from_api) )
|
||||||
return false;
|
return false;
|
||||||
if ( !is_array( $from_api->updates ) ) return false;
|
if ( !is_array( $from_api->updates ) ) return false;
|
||||||
|
@ -71,7 +71,7 @@ function undismiss_core_update( $version, $locale ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function find_core_update( $version, $locale ) {
|
function find_core_update( $version, $locale ) {
|
||||||
$from_api = get_option( 'update_core' );
|
$from_api = get_transient( 'update_core' );
|
||||||
if ( !is_array( $from_api->updates ) ) return false;
|
if ( !is_array( $from_api->updates ) ) return false;
|
||||||
$updates = $from_api->updates;
|
$updates = $from_api->updates;
|
||||||
foreach($updates as $update) {
|
foreach($updates as $update) {
|
||||||
|
@ -146,7 +146,7 @@ function update_right_now_message() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function wp_plugin_update_row( $file, $plugin_data ) {
|
function wp_plugin_update_row( $file, $plugin_data ) {
|
||||||
$current = get_option( 'update_plugins' );
|
$current = get_transient( 'update_plugins' );
|
||||||
if ( !isset( $current->response[ $file ] ) )
|
if ( !isset( $current->response[ $file ] ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ function wp_update_plugin($plugin, $feedback = '') {
|
||||||
add_filter('update_feedback', $feedback);
|
add_filter('update_feedback', $feedback);
|
||||||
|
|
||||||
// Is an update available?
|
// Is an update available?
|
||||||
$current = get_option( 'update_plugins' );
|
$current = get_transient( 'update_plugins' );
|
||||||
if ( !isset( $current->response[ $plugin ] ) )
|
if ( !isset( $current->response[ $plugin ] ) )
|
||||||
return new WP_Error('up_to_date', __('The plugin is at the latest version.'));
|
return new WP_Error('up_to_date', __('The plugin is at the latest version.'));
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ function wp_update_plugin($plugin, $feedback = '') {
|
||||||
$wp_filesystem->delete($working_dir, true);
|
$wp_filesystem->delete($working_dir, true);
|
||||||
|
|
||||||
// Force refresh of plugin update information
|
// Force refresh of plugin update information
|
||||||
delete_option('update_plugins');
|
delete_transient('update_plugins');
|
||||||
|
|
||||||
if( empty($filelist) )
|
if( empty($filelist) )
|
||||||
return false; //We couldnt find any files in the working dir, therefor no plugin installed? Failsafe backup.
|
return false; //We couldnt find any files in the working dir, therefor no plugin installed? Failsafe backup.
|
||||||
|
|
|
@ -58,7 +58,7 @@ $menu[40] = array( __('Appearance'), 'switch_themes', 'themes.php', '', 'menu-to
|
||||||
$submenu['themes.php'][5] = array(__('Themes'), 'switch_themes', 'themes.php');
|
$submenu['themes.php'][5] = array(__('Themes'), 'switch_themes', 'themes.php');
|
||||||
$submenu['themes.php'][10] = array(__('Editor'), 'edit_themes', 'theme-editor.php');
|
$submenu['themes.php'][10] = array(__('Editor'), 'edit_themes', 'theme-editor.php');
|
||||||
|
|
||||||
$update_plugins = get_option( 'update_plugins' );
|
$update_plugins = get_transient( 'update_plugins' );
|
||||||
$update_count = 0;
|
$update_count = 0;
|
||||||
if ( !empty($update_plugins->response) )
|
if ( !empty($update_plugins->response) )
|
||||||
$update_count = count( $update_plugins->response );
|
$update_count = count( $update_plugins->response );
|
||||||
|
|
|
@ -26,7 +26,7 @@ function wp_version_check() {
|
||||||
global $wp_version, $wpdb, $wp_local_package;
|
global $wp_version, $wpdb, $wp_local_package;
|
||||||
$php_version = phpversion();
|
$php_version = phpversion();
|
||||||
|
|
||||||
$current = get_option( 'update_core' );
|
$current = get_transient( 'update_core' );
|
||||||
if ( ! is_object($current) )
|
if ( ! is_object($current) )
|
||||||
$current = new stdClass;
|
$current = new stdClass;
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ function wp_version_check() {
|
||||||
|
|
||||||
// Update last_checked for current to prevent multiple blocking requests if request hangs
|
// Update last_checked for current to prevent multiple blocking requests if request hangs
|
||||||
$current->last_checked = time();
|
$current->last_checked = time();
|
||||||
update_option( 'update_core', $current );
|
set_transient( 'update_core', $current );
|
||||||
|
|
||||||
if ( method_exists( $wpdb, 'db_version' ) )
|
if ( method_exists( $wpdb, 'db_version' ) )
|
||||||
$mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version($wpdb->users));
|
$mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version($wpdb->users));
|
||||||
|
@ -84,7 +84,7 @@ function wp_version_check() {
|
||||||
$updates->updates = $new_options;
|
$updates->updates = $new_options;
|
||||||
$updates->last_checked = time();
|
$updates->last_checked = time();
|
||||||
$updates->version_checked = $wp_version;
|
$updates->version_checked = $wp_version;
|
||||||
update_option( 'update_core', $updates);
|
set_transient( 'update_core', $updates);
|
||||||
}
|
}
|
||||||
add_action( 'init', 'wp_version_check' );
|
add_action( 'init', 'wp_version_check' );
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ function wp_update_plugins() {
|
||||||
|
|
||||||
$plugins = get_plugins();
|
$plugins = get_plugins();
|
||||||
$active = get_option( 'active_plugins' );
|
$active = get_option( 'active_plugins' );
|
||||||
$current = get_option( 'update_plugins' );
|
$current = get_transient( 'update_plugins' );
|
||||||
if ( ! is_object($current) )
|
if ( ! is_object($current) )
|
||||||
$current = new stdClass;
|
$current = new stdClass;
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ function wp_update_plugins() {
|
||||||
|
|
||||||
// Update last_checked for current to prevent multiple blocking requests if request hangs
|
// Update last_checked for current to prevent multiple blocking requests if request hangs
|
||||||
$current->last_checked = time();
|
$current->last_checked = time();
|
||||||
update_option( 'update_plugins', $current );
|
set_transient( 'update_plugins', $current );
|
||||||
|
|
||||||
$to_send = (object)compact('plugins', 'active');
|
$to_send = (object)compact('plugins', 'active');
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ function wp_update_plugins() {
|
||||||
else
|
else
|
||||||
$new_option->response = array();
|
$new_option->response = array();
|
||||||
|
|
||||||
update_option( 'update_plugins', $new_option );
|
set_transient( 'update_plugins', $new_option );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -196,7 +196,7 @@ function wp_update_themes( ) {
|
||||||
require_once( ABSPATH . 'wp-includes/theme.php' );
|
require_once( ABSPATH . 'wp-includes/theme.php' );
|
||||||
|
|
||||||
$installed_themes = get_themes( );
|
$installed_themes = get_themes( );
|
||||||
$current_theme = get_option( 'update_themes' );
|
$current_theme = get_transient( 'update_themes' );
|
||||||
if ( ! is_object($current_theme) )
|
if ( ! is_object($current_theme) )
|
||||||
$current_theme = new stdClass;
|
$current_theme = new stdClass;
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ function wp_update_themes( ) {
|
||||||
|
|
||||||
// Update last_checked for current to prevent multiple blocking requests if request hangs
|
// Update last_checked for current to prevent multiple blocking requests if request hangs
|
||||||
$current_theme->last_checked = time();
|
$current_theme->last_checked = time();
|
||||||
update_option( 'update_themes', $current_theme );
|
set_transient( 'update_themes', $current_theme );
|
||||||
|
|
||||||
$themes = array( );
|
$themes = array( );
|
||||||
$themes['current_theme'] = $current_theme;
|
$themes['current_theme'] = $current_theme;
|
||||||
|
@ -240,7 +240,7 @@ function wp_update_themes( ) {
|
||||||
if( $response )
|
if( $response )
|
||||||
$new_option->response = $response;
|
$new_option->response = $response;
|
||||||
|
|
||||||
update_option( 'update_themes', $new_option );
|
set_transient( 'update_themes', $new_option );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -254,7 +254,7 @@ function wp_update_themes( ) {
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _maybe_update_plugins() {
|
function _maybe_update_plugins() {
|
||||||
$current = get_option( 'update_plugins' );
|
$current = get_transient( 'update_plugins' );
|
||||||
if ( isset( $current->last_checked ) && 43200 > ( time() - $current->last_checked ) )
|
if ( isset( $current->last_checked ) && 43200 > ( time() - $current->last_checked ) )
|
||||||
return;
|
return;
|
||||||
wp_update_plugins();
|
wp_update_plugins();
|
||||||
|
@ -270,7 +270,7 @@ function _maybe_update_plugins() {
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _maybe_update_themes( ) {
|
function _maybe_update_themes( ) {
|
||||||
$current = get_option( 'update_themes' );
|
$current = get_transient( 'update_themes' );
|
||||||
if( isset( $current->last_checked ) && 43200 > ( time( ) - $current->last_checked ) )
|
if( isset( $current->last_checked ) && 43200 > ( time( ) - $current->last_checked ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue