Ticket #22704: 22704.10.diff
| File 22704.10.diff, 2.2 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 1739 1741 $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 1742 1743 // Try to lock, in Multisite we always run in the context of the main site 1744 if ( is_multisite() && ! is_main_site() ) 1745 switch_to_blog( 1 ); 1746 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 ) { 1754 if ( is_multisite() ) 1755 restore_current_blog(); 1745 1756 return; 1757 } 1758 1759 // Check to see if the lock is still valid 1760 if ( $lock_result > ( time() - HOUR_IN_SECONDS ) ) { 1761 if ( is_multisite() ) 1762 restore_current_blog(); 1763 return; 1764 } 1746 1765 } 1747 // Lock upgrades for us for half an hour1748 if ( ! add_site_option( $lock_name, microtime( true ), HOUR_IN_SECONDS / 2 ) )1749 return;1750 1766 1767 // Update the lock, as by this point we've definately got a lock, just need to fire the actions 1768 update_option( $lock_name, time() ); 1769 1751 1770 // Don't automatically run these thins, as we'll handle it ourselves 1752 1771 remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 ); 1753 1772 remove_action( 'upgrader_process_complete', 'wp_version_check' ); … … 1829 1848 $this->send_debug_email(); 1830 1849 1831 1850 // Clear the lock 1832 delete_ site_option( $lock_name );1851 delete_option( $lock_name ); 1833 1852 1853 if ( is_multisite() ) 1854 restore_current_blog(); 1855 1834 1856 } 1835 1857 1836 1858 function send_debug_email() {