From 4e52545293d08a1217cbb2e0a7719b550f91bbaf Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Fri, 6 Feb 2009 18:06:20 +0000 Subject: [PATCH] Use transient for update_core, update_plugins, update_themes. see #9048 git-svn-id: https://develop.svn.wordpress.org/trunk@10515 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/update-core.php | 2 +- wp-admin/includes/update.php | 10 +++++----- wp-admin/menu.php | 2 +- wp-includes/update.php | 22 +++++++++++----------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/wp-admin/includes/update-core.php b/wp-admin/includes/update-core.php index 2e4781b2fe..36c55f4cdd 100644 --- a/wp-admin/includes/update-core.php +++ b/wp-admin/includes/update-core.php @@ -254,7 +254,7 @@ function update_core($from, $to) { $wp_filesystem->delete($from, true); // Force refresh of update information - delete_option('update_core'); + delete_transient('update_core'); // Remove maintenance file, we're done. $wp_filesystem->delete($maintenance_file); diff --git a/wp-admin/includes/update.php b/wp-admin/includes/update.php index c90bd7aae6..eedd91d2c9 100644 --- a/wp-admin/includes/update.php +++ b/wp-admin/includes/update.php @@ -33,7 +33,7 @@ function get_core_updates( $options = array() ) { $options = array_merge( array('available' => true, 'dismissed' => false ), $options ); $dismissed = get_option( 'dismissed_update_core' ); if ( !is_array( $dismissed ) ) $dismissed = array(); - $from_api = get_option( 'update_core' ); + $from_api = get_transient( 'update_core' ); if ( empty($from_api) ) 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 ) { - $from_api = get_option( 'update_core' ); + $from_api = get_transient( 'update_core' ); if ( !is_array( $from_api->updates ) ) return false; $updates = $from_api->updates; foreach($updates as $update) { @@ -146,7 +146,7 @@ function update_right_now_message() { } function wp_plugin_update_row( $file, $plugin_data ) { - $current = get_option( 'update_plugins' ); + $current = get_transient( 'update_plugins' ); if ( !isset( $current->response[ $file ] ) ) return false; @@ -173,7 +173,7 @@ function wp_update_plugin($plugin, $feedback = '') { add_filter('update_feedback', $feedback); // Is an update available? - $current = get_option( 'update_plugins' ); + $current = get_transient( 'update_plugins' ); if ( !isset( $current->response[ $plugin ] ) ) 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); // Force refresh of plugin update information - delete_option('update_plugins'); + delete_transient('update_plugins'); if( empty($filelist) ) return false; //We couldnt find any files in the working dir, therefor no plugin installed? Failsafe backup. diff --git a/wp-admin/menu.php b/wp-admin/menu.php index 209eb5870f..293d18a2f2 100644 --- a/wp-admin/menu.php +++ b/wp-admin/menu.php @@ -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'][10] = array(__('Editor'), 'edit_themes', 'theme-editor.php'); -$update_plugins = get_option( 'update_plugins' ); +$update_plugins = get_transient( 'update_plugins' ); $update_count = 0; if ( !empty($update_plugins->response) ) $update_count = count( $update_plugins->response ); diff --git a/wp-includes/update.php b/wp-includes/update.php index bd37647eeb..e6713da058 100644 --- a/wp-includes/update.php +++ b/wp-includes/update.php @@ -26,7 +26,7 @@ function wp_version_check() { global $wp_version, $wpdb, $wp_local_package; $php_version = phpversion(); - $current = get_option( 'update_core' ); + $current = get_transient( 'update_core' ); if ( ! is_object($current) ) $current = new stdClass; @@ -40,7 +40,7 @@ function wp_version_check() { // Update last_checked for current to prevent multiple blocking requests if request hangs $current->last_checked = time(); - update_option( 'update_core', $current ); + set_transient( 'update_core', $current ); if ( method_exists( $wpdb, 'db_version' ) ) $mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version($wpdb->users)); @@ -84,7 +84,7 @@ function wp_version_check() { $updates->updates = $new_options; $updates->last_checked = time(); $updates->version_checked = $wp_version; - update_option( 'update_core', $updates); + set_transient( 'update_core', $updates); } add_action( 'init', 'wp_version_check' ); @@ -113,7 +113,7 @@ function wp_update_plugins() { $plugins = get_plugins(); $active = get_option( 'active_plugins' ); - $current = get_option( 'update_plugins' ); + $current = get_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(); - update_option( 'update_plugins', $current ); + set_transient( 'update_plugins', $current ); $to_send = (object)compact('plugins', 'active'); @@ -170,7 +170,7 @@ function wp_update_plugins() { else $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' ); $installed_themes = get_themes( ); - $current_theme = get_option( 'update_themes' ); + $current_theme = get_transient( 'update_themes' ); if ( ! is_object($current_theme) ) $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 $current_theme->last_checked = time(); - update_option( 'update_themes', $current_theme ); + set_transient( 'update_themes', $current_theme ); $themes = array( ); $themes['current_theme'] = $current_theme; @@ -240,7 +240,7 @@ function wp_update_themes( ) { if( $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 */ function _maybe_update_plugins() { - $current = get_option( 'update_plugins' ); + $current = get_transient( 'update_plugins' ); if ( isset( $current->last_checked ) && 43200 > ( time() - $current->last_checked ) ) return; wp_update_plugins(); @@ -270,7 +270,7 @@ function _maybe_update_plugins() { * @access private */ function _maybe_update_themes( ) { - $current = get_option( 'update_themes' ); + $current = get_transient( 'update_themes' ); if( isset( $current->last_checked ) && 43200 > ( time( ) - $current->last_checked ) ) return;