Skip to content

Commit 4e52545

Browse files
committed
Use transient for update_core, update_plugins, update_themes. see WordPress#9048
git-svn-id: https://develop.svn.wordpress.org/trunk@10515 602fd350-edb4-49c9-b593-d223f7449a82
1 parent ac427bb commit 4e52545

4 files changed

Lines changed: 18 additions & 18 deletions

File tree

wp-admin/includes/update-core.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ function update_core($from, $to) {
254254
$wp_filesystem->delete($from, true);
255255

256256
// Force refresh of update information
257-
delete_option('update_core');
257+
delete_transient('update_core');
258258

259259
// Remove maintenance file, we're done.
260260
$wp_filesystem->delete($maintenance_file);

wp-admin/includes/update.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function get_core_updates( $options = array() ) {
3333
$options = array_merge( array('available' => true, 'dismissed' => false ), $options );
3434
$dismissed = get_option( 'dismissed_update_core' );
3535
if ( !is_array( $dismissed ) ) $dismissed = array();
36-
$from_api = get_option( 'update_core' );
36+
$from_api = get_transient( 'update_core' );
3737
if ( empty($from_api) )
3838
return false;
3939
if ( !is_array( $from_api->updates ) ) return false;
@@ -71,7 +71,7 @@ function undismiss_core_update( $version, $locale ) {
7171
}
7272

7373
function find_core_update( $version, $locale ) {
74-
$from_api = get_option( 'update_core' );
74+
$from_api = get_transient( 'update_core' );
7575
if ( !is_array( $from_api->updates ) ) return false;
7676
$updates = $from_api->updates;
7777
foreach($updates as $update) {
@@ -146,7 +146,7 @@ function update_right_now_message() {
146146
}
147147

148148
function wp_plugin_update_row( $file, $plugin_data ) {
149-
$current = get_option( 'update_plugins' );
149+
$current = get_transient( 'update_plugins' );
150150
if ( !isset( $current->response[ $file ] ) )
151151
return false;
152152

@@ -173,7 +173,7 @@ function wp_update_plugin($plugin, $feedback = '') {
173173
add_filter('update_feedback', $feedback);
174174

175175
// Is an update available?
176-
$current = get_option( 'update_plugins' );
176+
$current = get_transient( 'update_plugins' );
177177
if ( !isset( $current->response[ $plugin ] ) )
178178
return new WP_Error('up_to_date', __('The plugin is at the latest version.'));
179179

@@ -268,7 +268,7 @@ function wp_update_plugin($plugin, $feedback = '') {
268268
$wp_filesystem->delete($working_dir, true);
269269

270270
// Force refresh of plugin update information
271-
delete_option('update_plugins');
271+
delete_transient('update_plugins');
272272

273273
if( empty($filelist) )
274274
return false; //We couldnt find any files in the working dir, therefor no plugin installed? Failsafe backup.

wp-admin/menu.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
$submenu['themes.php'][5] = array(__('Themes'), 'switch_themes', 'themes.php');
5959
$submenu['themes.php'][10] = array(__('Editor'), 'edit_themes', 'theme-editor.php');
6060

61-
$update_plugins = get_option( 'update_plugins' );
61+
$update_plugins = get_transient( 'update_plugins' );
6262
$update_count = 0;
6363
if ( !empty($update_plugins->response) )
6464
$update_count = count( $update_plugins->response );

wp-includes/update.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function wp_version_check() {
2626
global $wp_version, $wpdb, $wp_local_package;
2727
$php_version = phpversion();
2828

29-
$current = get_option( 'update_core' );
29+
$current = get_transient( 'update_core' );
3030
if ( ! is_object($current) )
3131
$current = new stdClass;
3232

@@ -40,7 +40,7 @@ function wp_version_check() {
4040

4141
// Update last_checked for current to prevent multiple blocking requests if request hangs
4242
$current->last_checked = time();
43-
update_option( 'update_core', $current );
43+
set_transient( 'update_core', $current );
4444

4545
if ( method_exists( $wpdb, 'db_version' ) )
4646
$mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version($wpdb->users));
@@ -84,7 +84,7 @@ function wp_version_check() {
8484
$updates->updates = $new_options;
8585
$updates->last_checked = time();
8686
$updates->version_checked = $wp_version;
87-
update_option( 'update_core', $updates);
87+
set_transient( 'update_core', $updates);
8888
}
8989
add_action( 'init', 'wp_version_check' );
9090

@@ -113,7 +113,7 @@ function wp_update_plugins() {
113113

114114
$plugins = get_plugins();
115115
$active = get_option( 'active_plugins' );
116-
$current = get_option( 'update_plugins' );
116+
$current = get_transient( 'update_plugins' );
117117
if ( ! is_object($current) )
118118
$current = new stdClass;
119119

@@ -145,7 +145,7 @@ function wp_update_plugins() {
145145

146146
// Update last_checked for current to prevent multiple blocking requests if request hangs
147147
$current->last_checked = time();
148-
update_option( 'update_plugins', $current );
148+
set_transient( 'update_plugins', $current );
149149

150150
$to_send = (object)compact('plugins', 'active');
151151

@@ -170,7 +170,7 @@ function wp_update_plugins() {
170170
else
171171
$new_option->response = array();
172172

173-
update_option( 'update_plugins', $new_option );
173+
set_transient( 'update_plugins', $new_option );
174174
}
175175

176176
/**
@@ -196,7 +196,7 @@ function wp_update_themes( ) {
196196
require_once( ABSPATH . 'wp-includes/theme.php' );
197197

198198
$installed_themes = get_themes( );
199-
$current_theme = get_option( 'update_themes' );
199+
$current_theme = get_transient( 'update_themes' );
200200
if ( ! is_object($current_theme) )
201201
$current_theme = new stdClass;
202202

@@ -210,7 +210,7 @@ function wp_update_themes( ) {
210210

211211
// Update last_checked for current to prevent multiple blocking requests if request hangs
212212
$current_theme->last_checked = time();
213-
update_option( 'update_themes', $current_theme );
213+
set_transient( 'update_themes', $current_theme );
214214

215215
$themes = array( );
216216
$themes['current_theme'] = $current_theme;
@@ -240,7 +240,7 @@ function wp_update_themes( ) {
240240
if( $response )
241241
$new_option->response = $response;
242242

243-
update_option( 'update_themes', $new_option );
243+
set_transient( 'update_themes', $new_option );
244244
}
245245

246246
/**
@@ -254,7 +254,7 @@ function wp_update_themes( ) {
254254
* @access private
255255
*/
256256
function _maybe_update_plugins() {
257-
$current = get_option( 'update_plugins' );
257+
$current = get_transient( 'update_plugins' );
258258
if ( isset( $current->last_checked ) && 43200 > ( time() - $current->last_checked ) )
259259
return;
260260
wp_update_plugins();
@@ -270,7 +270,7 @@ function _maybe_update_plugins() {
270270
* @access private
271271
*/
272272
function _maybe_update_themes( ) {
273-
$current = get_option( 'update_themes' );
273+
$current = get_transient( 'update_themes' );
274274
if( isset( $current->last_checked ) && 43200 > ( time( ) - $current->last_checked ) )
275275
return;
276276

0 commit comments

Comments
 (0)