Check for plugin and theme updates more often when visitng update-core.php. Props kurtpayne. fixes #18876

git-svn-id: http://svn.automattic.com/wordpress/trunk@19683 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2012-01-05 19:49:47 +00:00
parent f809fda4e7
commit fafe61b247
1 changed files with 68 additions and 34 deletions

View File

@ -34,6 +34,12 @@ function wp_version_check() {
$current->version_checked = $wp_version; $current->version_checked = $wp_version;
} }
// Wait 60 seconds between multiple version check requests
$timeout = 60;
$time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked );
if ( $time_not_changed )
return false;
$locale = apply_filters( 'core_version_check_locale', get_locale() ); $locale = apply_filters( 'core_version_check_locale', get_locale() );
// Update last_checked for current to prevent multiple blocking requests if request hangs // Update last_checked for current to prevent multiple blocking requests if request hangs
@ -143,10 +149,23 @@ function wp_update_plugins() {
$new_option = new stdClass; $new_option = new stdClass;
$new_option->last_checked = time(); $new_option->last_checked = time();
// Check for updated every 60 minutes if hitting update pages; else, check every 12 hours.
$timeout = in_array( current_filter(), array( 'load-plugins.php', 'load-update.php', 'load-update-core.php' ) ) ? 3600 : 43200; // Check for update on a different schedule, depending on the page.
switch ( current_filter() ) {
case 'load-update-core.php' :
$timeout = 60; // 1 min
break;
case 'load-plugins.php' :
case 'load-update.php' :
$timeout = 3600; // 1 hour
break;
default :
$timeout = 43200; // 12 hours
}
$time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked ); $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked );
if ( $time_not_changed ) {
$plugin_changed = false; $plugin_changed = false;
foreach ( $plugins as $file => $p ) { foreach ( $plugins as $file => $p ) {
$new_option->checked[ $file ] = $p['Version']; $new_option->checked[ $file ] = $p['Version'];
@ -164,9 +183,10 @@ function wp_update_plugins() {
} }
} }
// Bail if we've checked in the last 12 hours and if nothing has changed // Bail if we've checked recently and if nothing has changed
if ( $time_not_changed && !$plugin_changed ) if ( ! $plugin_changed )
return false; return false;
}
// Update last_checked for current to prevent multiple blocking requests if request hangs // Update last_checked for current to prevent multiple blocking requests if request hangs
$current->last_checked = time(); $current->last_checked = time();
@ -222,10 +242,6 @@ function wp_update_themes() {
if ( ! is_object($last_update) ) if ( ! is_object($last_update) )
$last_update = new stdClass; $last_update = new stdClass;
// Check for updated every 60 minutes if hitting update pages; else, check every 12 hours.
$timeout = in_array( current_filter(), array( 'load-themes.php', 'load-update.php', 'load-update-core.php' ) ) ? 3600 : 43200;
$time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time( ) - $last_update->last_checked );
$themes = array(); $themes = array();
$checked = array(); $checked = array();
$exclude_fields = array('Template Files', 'Stylesheet Files', 'Status', 'Theme Root', 'Theme Root URI', 'Template Dir', 'Stylesheet Dir', 'Description', 'Tags', 'Screenshot'); $exclude_fields = array('Template Files', 'Stylesheet Files', 'Status', 'Theme Root', 'Theme Root URI', 'Template Dir', 'Stylesheet Dir', 'Description', 'Tags', 'Screenshot');
@ -246,6 +262,22 @@ function wp_update_themes() {
} }
} }
// Check for update on a different schedule, depending on the page.
switch ( current_filter() ) {
case 'load-update-core.php' :
$timeout = 60; // 1 min
break;
case 'load-plugins.php' :
case 'load-update.php' :
$timeout = 3600; // 1 hour
break;
default :
$timeout = 43200; // 12 hours
}
$time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time( ) - $last_update->last_checked );
if ( $time_not_changed ) {
$theme_changed = false; $theme_changed = false;
foreach ( $checked as $slug => $v ) { foreach ( $checked as $slug => $v ) {
$update_request->checked[ $slug ] = $v; $update_request->checked[ $slug ] = $v;
@ -263,8 +295,10 @@ function wp_update_themes() {
} }
} }
if ( $time_not_changed && !$theme_changed ) // Bail if we've checked recently and if nothing has changed
if ( ! $theme_changed )
return false; return false;
}
// Update last_checked for current to prevent multiple blocking requests if request hangs // Update last_checked for current to prevent multiple blocking requests if request hangs
$last_update->last_checked = time(); $last_update->last_checked = time();