Convert update_themes, update_plugins, update_core, and dismissed_update_core into site transients/plugins. Remove no longer need compat code.

git-svn-id: http://svn.automattic.com/wordpress/trunk@12673 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-01-08 20:49:55 +00:00
parent dea7019303
commit 166435891c
13 changed files with 43 additions and 123 deletions

View File

@ -398,7 +398,7 @@ class Plugin_Upgrader extends WP_Upgrader {
));
// Force refresh of plugin update information
delete_transient('update_plugins');
delete_site_transient('update_plugins');
}
@ -407,7 +407,7 @@ class Plugin_Upgrader extends WP_Upgrader {
$this->init();
$this->upgrade_strings();
$current = get_transient( 'update_plugins' );
$current = get_site_transient( 'update_plugins' );
if ( !isset( $current->response[ $plugin ] ) ) {
$this->skin->set_result(false);
$this->skin->error('up_to_date');
@ -440,7 +440,7 @@ class Plugin_Upgrader extends WP_Upgrader {
return $this->result;
// Force refresh of plugin update information
delete_transient('update_plugins');
delete_site_transient('update_plugins');
}
function bulk_upgrade($plugins) {
@ -449,7 +449,7 @@ class Plugin_Upgrader extends WP_Upgrader {
$this->bulk = true;
$this->upgrade_strings();
$current = get_transient( 'update_plugins' );
$current = get_site_transient( 'update_plugins' );
add_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'), 10, 4);
@ -508,7 +508,7 @@ class Plugin_Upgrader extends WP_Upgrader {
remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'));
// Force refresh of plugin update information
delete_transient('update_plugins');
delete_site_transient('update_plugins');
return $results;
}
@ -627,7 +627,7 @@ class Theme_Upgrader extends WP_Upgrader {
return $this->result;
// Force refresh of theme update information
delete_transient('update_themes');
delete_site_transient('update_themes');
if ( empty($result['destination_name']) )
return false;
@ -641,7 +641,7 @@ class Theme_Upgrader extends WP_Upgrader {
$this->upgrade_strings();
// Is an update available?
$current = get_transient( 'update_themes' );
$current = get_site_transient( 'update_themes' );
if ( !isset( $current->response[ $theme ] ) ) {
$this->skin->set_result(false);
$this->skin->error('up_to_date');
@ -671,7 +671,7 @@ class Theme_Upgrader extends WP_Upgrader {
return $this->result;
// Force refresh of theme update information
delete_transient('update_themes');
delete_site_transient('update_themes');
return true;
}

View File

@ -443,7 +443,7 @@ function install_plugin_information() {
//Default to a "new" plugin
$type = 'install';
//Check to see if this plugin is known to be installed, and has an update awaiting it.
$update_plugins = get_transient('update_plugins');
$update_plugins = get_site_transient('update_plugins');
if ( is_object( $update_plugins ) ) {
foreach ( (array)$update_plugins->response as $file => $plugin ) {
if ( $plugin->slug === $api->slug ) {
@ -464,7 +464,7 @@ function install_plugin_information() {
$newer_version = $installed_plugin[ $key ]['Version'];
} else {
//If the above update check failed, Then that probably means that the update checker has out-of-date information, force a refresh
delete_transient('update_plugins');
delete_site_transient('update_plugins');
$update_file = $api->slug . '/' . $key; //This code branch only deals with a plugin which is in a folder the same name as its slug, Doesnt support plugins which have 'non-standard' names
$type = 'update_available';
}

View File

@ -467,9 +467,9 @@ function delete_plugins($plugins, $redirect = '' ) {
return new WP_Error('could_not_remove_plugin', sprintf(__('Could not fully remove the plugin(s) %s'), implode(', ', $errors)) );
// Force refresh of plugin update information
if ( $current = get_transient('update_plugins') ) {
if ( $current = get_site_transient('update_plugins') ) {
unset( $current->response[ $plugin_file ] );
set_transient('update_plugins', $current);
set_site_transient('update_plugins', $current);
}
return true;

View File

@ -476,7 +476,7 @@ function install_theme_information() {
// Default to a "new" theme
$type = 'install';
// Check to see if this theme is known to be installed, and has an update awaiting it.
$update_themes = get_transient('update_themes');
$update_themes = get_site_transient('update_themes');
if ( is_object($update_themes) && isset($update_themes->response) ) {
foreach ( (array)$update_themes->response as $theme_slug => $theme_info ) {
if ( $theme_slug === $api->slug ) {

View File

@ -97,7 +97,7 @@ function delete_theme($template) {
return new WP_Error('could_not_remove_theme', sprintf(__('Could not fully remove the theme %s'), $template) );
// Force refresh of theme update information
delete_transient('update_themes');
delete_site_transient('update_themes');
return true;
}

View File

@ -278,8 +278,8 @@ function update_core($from, $to) {
$wp_filesystem->delete($from, true);
// Force refresh of update information
if ( function_exists('delete_transient') )
delete_transient('update_core');
if ( function_exists('delete_site_transient') )
delete_site_transient('update_core');
else
delete_option('update_core');

View File

@ -31,9 +31,9 @@ function get_preferred_from_update_core() {
*/
function get_core_updates( $options = array() ) {
$options = array_merge( array('available' => true, 'dismissed' => false ), $options );
$dismissed = get_option( 'dismissed_update_core' );
$dismissed = get_site_option( 'dismissed_update_core' );
if ( !is_array( $dismissed ) ) $dismissed = array();
$from_api = get_transient( 'update_core' );
$from_api = get_site_transient( 'update_core' );
if ( empty($from_api) )
return false;
if ( !isset( $from_api->updates ) || !is_array( $from_api->updates ) ) return false;
@ -57,21 +57,21 @@ function get_core_updates( $options = array() ) {
}
function dismiss_core_update( $update ) {
$dismissed = get_option( 'dismissed_update_core' );
$dismissed = get_site_option( 'dismissed_update_core' );
$dismissed[ $update->current.'|'.$update->locale ] = true;
return update_option( 'dismissed_update_core', $dismissed );
return update_site_option( 'dismissed_update_core', $dismissed );
}
function undismiss_core_update( $version, $locale ) {
$dismissed = get_option( 'dismissed_update_core' );
$dismissed = get_site_option( 'dismissed_update_core' );
$key = $version.'|'.$locale;
if ( !isset( $dismissed[$key] ) ) return false;
unset( $dismissed[$key] );
return update_option( 'dismissed_update_core', $dismissed );
return update_site_option( 'dismissed_update_core', $dismissed );
}
function find_core_update( $version, $locale ) {
$from_api = get_transient( 'update_core' );
$from_api = get_site_transient( 'update_core' );
if ( !is_array( $from_api->updates ) ) return false;
$updates = $from_api->updates;
foreach($updates as $update) {
@ -148,7 +148,7 @@ function update_right_now_message() {
function get_plugin_updates() {
$all_plugins = get_plugins();
$upgrade_plugins = array();
$current = get_transient( 'update_plugins' );
$current = get_site_transient( 'update_plugins' );
foreach ( (array)$all_plugins as $plugin_file => $plugin_data) {
if ( isset( $current->response[ $plugin_file ] ) ) {
$upgrade_plugins[ $plugin_file ] = (object) $plugin_data;
@ -160,7 +160,7 @@ function get_plugin_updates() {
}
function wp_plugin_update_rows() {
$plugins = get_transient( 'update_plugins' );
$plugins = get_site_transient( 'update_plugins' );
if ( isset($plugins->response) && is_array($plugins->response) ) {
$plugins = array_keys( $plugins->response );
foreach( $plugins as $plugin_file ) {
@ -171,7 +171,7 @@ function wp_plugin_update_rows() {
add_action( 'admin_init', 'wp_plugin_update_rows' );
function wp_plugin_update_row( $file, $plugin_data ) {
$current = get_transient( 'update_plugins' );
$current = get_site_transient( 'update_plugins' );
if ( !isset( $current->response[ $file ] ) )
return false;
@ -207,7 +207,7 @@ function wp_update_plugin($plugin, $feedback = '') {
function get_theme_updates() {
$themes = get_themes();
$current = get_transient('update_themes');
$current = get_site_transient('update_themes');
$update_themes = array();
foreach ( $themes as $theme ) {

View File

@ -104,7 +104,7 @@ $menu[60] = array( __('Appearance'), 'switch_themes', 'themes.php', '', 'menu-to
if ( is_super_admin() )
$submenu['themes.php'][15] = array(__('Add New Themes'), 'install_themes', 'theme-install.php');
$update_plugins = get_transient( 'update_plugins' );
$update_plugins = get_site_transient( 'update_plugins' );
$update_count = 0;
if ( !empty($update_plugins->response) )
$update_count = count( $update_plugins->response );

View File

@ -302,7 +302,7 @@ foreach ( $recently_activated as $key => $time )
unset($recently_activated[ $key ]);
if ( $recently_activated != get_option('recently_activated') ) //If array changed, update it.
update_option('recently_activated', $recently_activated);
$current = get_transient( 'update_plugins' );
$current = get_site_transient( 'update_plugins' );
foreach ( (array)$all_plugins as $plugin_file => $plugin_data) {

View File

@ -98,7 +98,7 @@ $themes = array_slice( $themes, $start, $per_page );
function theme_update_available( $theme ) {
static $themes_update;
if ( !isset($themes_update) )
$themes_update = get_transient('update_themes');
$themes_update = get_site_transient('update_themes');
if ( is_object($theme) && isset($theme->stylesheet) )
$stylesheet = $theme->stylesheet;

View File

@ -20,7 +20,7 @@ require( '../wp-load.php' );
timer_start();
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
delete_transient('update_core');
delete_site_transient('update_core');
if ( isset( $_GET['step'] ) )
$step = $_GET['step'];

View File

@ -2088,86 +2088,6 @@ function strtolower_usernames( $username, $raw, $strict ) {
return strtolower( $username );
}
/* Short circuit the update checks. Make sure update informtion is
stored in wp_sitemeta rather than the options table of individual blogs */
// update_plugins (transient)
function site_delete_update_plugins() {
return update_site_option( 'update_plugins', false );
}
add_action( 'delete_transient_update_plugins', 'site_delete_update_plugins' );
function site_pre_update_plugins() {
return get_site_option( 'update_plugins' );
}
add_filter( 'pre_transient_update_plugins', 'site_pre_update_plugins' );
function site_pre_set_transient_update_plugins( $value ) {
update_site_option( 'update_plugins', $value );
return $value;
}
add_filter( 'pre_set_transient_update_plugins', 'site_pre_set_transient_update_plugins' );
add_action( 'add_option__transient_update_plugins', 'site_add_option__transient_update');
// update_themes (transient)
function site_delete_update_themes() {
return update_site_option( 'update_themes', false );
}
add_action( 'delete_transient_update_themes', 'site_delete_update_themes' );
function site_pre_update_themes() {
return get_site_option( 'update_themes' );
}
add_filter( 'pre_transient_update_themes', 'site_pre_update_themes' );
function site_pre_set_transient_update_themes( $value ) {
update_site_option( 'update_themes', $value );
return $value;
}
add_filter( 'pre_set_transient_update_themes', 'site_pre_set_transient_update_themes' );
add_action( 'add_option__transient_update_themes', 'site_add_option__transient_update');
// update_core (transient)
function site_delete_update_core() {
return update_site_option( 'update_core', false );
}
add_action( 'delete_transient_update_core', 'site_delete_update_core' );
function site_pre_update_core() {
return get_site_option( 'update_core' );
}
add_filter( 'pre_transient_update_core', 'site_pre_update_core' );
function site_pre_set_transient_update_core( $value ) {
update_site_option( 'update_core', $value );
return $value;
}
add_filter( 'pre_set_transient_update_core', 'site_pre_set_transient_update_core' );
add_action( 'add_option__transient_update_core', 'site_add_option__transient_update');
// dismissed_update_core (option, not a transient)
function site_pre_dismissed_update_core() {
return get_site_option( 'dismissed_update_core' );
}
add_filter( 'pre_option_dismissed_update_core', 'site_pre_dismissed_update_core' );
function site_pre_update_option_dismissed_update_core( $newvalue, $oldvalue ) {
update_site_option( 'dismissed_update_core', $newvalue );
delete_option('dismissed_update_core');
// Return the old value so the update_option() call is aborted after this filter is run. It's in sitemeta now.
return $oldvalue;
}
add_filter( 'pre_update_option_dismissed_update_core', 'site_pre_update_option_dismissed_update_core', 10, 2 );
function site_add_option__transient_update($name) {
delete_option($name);
}
/* Redirect all hits to "dashboard" blog to wp-admin/ Dashboard. */
function redirect_mu_dashboard() {
global $current_site, $current_blog;

View File

@ -26,7 +26,7 @@ function wp_version_check() {
global $wp_version, $wpdb, $wp_local_package;
$php_version = phpversion();
$current = get_transient( 'update_core' );
$current = get_site_transient( 'update_core' );
if ( ! is_object($current) ) {
$current = new stdClass;
$current->updates = array();
@ -37,7 +37,7 @@ function wp_version_check() {
// Update last_checked for current to prevent multiple blocking requests if request hangs
$current->last_checked = time();
set_transient( 'update_core', $current );
set_site_transient( 'update_core', $current );
if ( method_exists( $wpdb, 'db_version' ) )
$mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version());
@ -85,7 +85,7 @@ function wp_version_check() {
$updates->updates = $new_options;
$updates->last_checked = time();
$updates->version_checked = $wp_version;
set_transient( 'update_core', $updates);
set_site_transient( 'update_core', $updates);
}
/**
@ -113,7 +113,7 @@ function wp_update_plugins() {
$plugins = get_plugins();
$active = get_option( 'active_plugins' );
$current = get_transient( 'update_plugins' );
$current = get_site_transient( 'update_plugins' );
if ( ! is_object($current) )
$current = new stdClass;
@ -145,7 +145,7 @@ function wp_update_plugins() {
// Update last_checked for current to prevent multiple blocking requests if request hangs
$current->last_checked = time();
set_transient( 'update_plugins', $current );
set_site_transient( 'update_plugins', $current );
$to_send = (object)compact('plugins', 'active');
@ -170,7 +170,7 @@ function wp_update_plugins() {
else
$new_option->response = array();
set_transient( 'update_plugins', $new_option );
set_site_transient( 'update_plugins', $new_option );
}
/**
@ -196,7 +196,7 @@ function wp_update_themes( ) {
require_once( ABSPATH . 'wp-includes/theme.php' );
$installed_themes = get_themes( );
$current_theme = get_transient( 'update_themes' );
$current_theme = get_site_transient( 'update_themes' );
if ( ! is_object($current_theme) )
$current_theme = new stdClass;
@ -239,7 +239,7 @@ function wp_update_themes( ) {
// Update last_checked for current to prevent multiple blocking requests if request hangs
$current_theme->last_checked = time();
set_transient( 'update_themes', $current_theme );
set_site_transient( 'update_themes', $current_theme );
$current_theme->template = get_option( 'template' );
@ -263,13 +263,13 @@ function wp_update_themes( ) {
$new_option->response = $response;
}
set_transient( 'update_themes', $new_option );
set_site_transient( 'update_themes', $new_option );
}
function _maybe_update_core() {
global $wp_version;
$current = get_transient( 'update_core' );
$current = get_site_transient( 'update_core' );
if ( isset( $current->last_checked ) &&
43200 > ( time() - $current->last_checked ) &&
@ -290,7 +290,7 @@ function _maybe_update_core() {
* @access private
*/
function _maybe_update_plugins() {
$current = get_transient( 'update_plugins' );
$current = get_site_transient( 'update_plugins' );
if ( isset( $current->last_checked ) && 43200 > ( time() - $current->last_checked ) )
return;
wp_update_plugins();
@ -306,7 +306,7 @@ function _maybe_update_plugins() {
* @access private
*/
function _maybe_update_themes( ) {
$current = get_transient( 'update_themes' );
$current = get_site_transient( 'update_themes' );
if( isset( $current->last_checked ) && 43200 > ( time( ) - $current->last_checked ) )
return;