From cc84220ab5720a3d955bd93da2cbff3939abbb8b Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Tue, 17 Sep 2013 02:28:09 +0000 Subject: [PATCH] WordPress Core Automatic Updates: Switch from using a transient for locking the upgrade process, to using a site option. See #22704 Built from https://develop.svn.wordpress.org/trunk@25467 git-svn-id: http://core.svn.wordpress.org/trunk@25388 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-upgrader.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/wp-admin/includes/class-wp-upgrader.php b/wp-admin/includes/class-wp-upgrader.php index ba4672addd..542d8a40c5 100644 --- a/wp-admin/includes/class-wp-upgrader.php +++ b/wp-admin/includes/class-wp-upgrader.php @@ -1448,15 +1448,17 @@ class WP_Automatic_Upgrader { static function perform_auto_updates() { $lock_name = 'auto_upgrader.lock'; - if ( get_site_transient( $lock_name ) ) { + if ( get_site_option( $lock_name ) ) { // Test to see if it was set more than an hour ago, if so, cleanup. - if ( true || get_site_transient( $lock_name ) < ( time() - HOUR_IN_SECONDS ) ) - delete_site_transient( $lock_name ); - else // Recent lock + if ( get_site_option( $lock_name ) < ( time() - HOUR_IN_SECONDS ) ) + delete_site_option( $lock_name ); + else { // The process is already locked + echo "There's a lock in place"; return; + } } // Lock upgrades for us for half an hour - if ( ! set_site_transient( $lock_name, microtime( true ), HOUR_IN_SECONDS / 2 ) ) + if ( ! add_site_option( $lock_name, microtime( true ), HOUR_IN_SECONDS / 2 ) ) return; // Next, Plugins @@ -1492,8 +1494,8 @@ class WP_Automatic_Upgrader { wp_update_themes(); // Check for Theme updates wp_update_plugins(); // Check for Plugin updates - // TODO The core database upgrade has already cleared this transient.. - delete_site_transient( $lock_name ); + // Clear the lock + delete_site_option( $lock_name ); }