Ticket #22704: 22704.11.diff
| File 22704.11.diff, 2.0 KB (added by , 12 years ago) |
|---|
-
src/wp-admin/includes/class-wp-upgrader.php
1736 1736 * Kicks off a upgrade request for each item in the upgrade "queue" 1737 1737 */ 1738 1738 function run() { 1739 global $wpdb; 1740 1741 if ( is_multisite() && ( ! is_main_network() || ! is_main_site() ) ) 1742 return; 1743 1739 1744 $lock_name = 'auto_upgrader.lock'; 1740 if ( get_site_option( $lock_name ) ) { 1741 // Test to see if it was set more than an hour ago, if so, cleanup. 1742 if ( get_site_option( $lock_name ) < ( time() - HOUR_IN_SECONDS ) ) 1743 delete_site_option( $lock_name ); 1744 else // The process is already locked 1745 1746 // Try to lock 1747 $lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_name, time() ) ); 1748 1749 if ( ! $lock_result ) { 1750 $lock_result = get_option( $lock_name ); 1751 1752 // If we couldn't create a lock, and there isn't a lock, bail 1753 if ( ! $lock_result ) 1745 1754 return; 1755 1756 // Check to see if the lock is still valid 1757 if ( $lock_result > ( time() - HOUR_IN_SECONDS ) ) 1758 return; 1746 1759 } 1747 // Lock upgrades for us for half an hour1748 if ( ! add_site_option( $lock_name, microtime( true ), HOUR_IN_SECONDS / 2 ) )1749 return;1750 1760 1761 // Update the lock, as by this point we've definately got a lock, just need to fire the actions 1762 update_option( $lock_name, time() ); 1763 1751 1764 // Don't automatically run these thins, as we'll handle it ourselves 1752 1765 remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 ); 1753 1766 remove_action( 'upgrader_process_complete', 'wp_version_check' ); … … 1829 1842 $this->send_debug_email(); 1830 1843 1831 1844 // Clear the lock 1832 delete_site_option( $lock_name ); 1833 1845 delete_option( $lock_name ); 1834 1846 } 1835 1847 1836 1848 function send_debug_email() {