mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-04 12:44:31 +00:00
Cron API: Add a new wp_doing_cron() helper function.
This replaces `DOING_CRON` checks via the constant. Props tfrommen. Fixes #39591. git-svn-id: https://develop.svn.wordpress.org/trunk@40575 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -108,8 +108,10 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) {
|
||||
if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
|
||||
$url = set_url_scheme( $url, 'https' );
|
||||
|
||||
$doing_cron = wp_doing_cron();
|
||||
|
||||
$options = array(
|
||||
'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ),
|
||||
'timeout' => $doing_cron ? 30 : 3,
|
||||
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
|
||||
'headers' => array(
|
||||
'wp_install' => $wp_install,
|
||||
@@ -177,7 +179,7 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) {
|
||||
}
|
||||
|
||||
// Trigger background updates if running non-interactively, and we weren't called from the update handler.
|
||||
if ( defined( 'DOING_CRON' ) && DOING_CRON && ! doing_action( 'wp_maybe_auto_update' ) ) {
|
||||
if ( $doing_cron && ! doing_action( 'wp_maybe_auto_update' ) ) {
|
||||
do_action( 'wp_maybe_auto_update' );
|
||||
}
|
||||
}
|
||||
@@ -217,6 +219,8 @@ function wp_update_plugins( $extra_stats = array() ) {
|
||||
$new_option = new stdClass;
|
||||
$new_option->last_checked = time();
|
||||
|
||||
$doing_cron = wp_doing_cron();
|
||||
|
||||
// Check for update on a different schedule, depending on the page.
|
||||
switch ( current_filter() ) {
|
||||
case 'upgrader_process_complete' :
|
||||
@@ -230,7 +234,7 @@ function wp_update_plugins( $extra_stats = array() ) {
|
||||
$timeout = HOUR_IN_SECONDS;
|
||||
break;
|
||||
default :
|
||||
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
|
||||
if ( $doing_cron ) {
|
||||
$timeout = 0;
|
||||
} else {
|
||||
$timeout = 12 * HOUR_IN_SECONDS;
|
||||
@@ -282,7 +286,7 @@ function wp_update_plugins( $extra_stats = array() ) {
|
||||
$locales = apply_filters( 'plugins_update_check_locales', $locales );
|
||||
$locales = array_unique( $locales );
|
||||
|
||||
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
|
||||
if ( $doing_cron ) {
|
||||
$timeout = 30;
|
||||
} else {
|
||||
// Three seconds, plus one extra second for every 10 plugins
|
||||
@@ -400,6 +404,8 @@ function wp_update_themes( $extra_stats = array() ) {
|
||||
);
|
||||
}
|
||||
|
||||
$doing_cron = wp_doing_cron();
|
||||
|
||||
// Check for update on a different schedule, depending on the page.
|
||||
switch ( current_filter() ) {
|
||||
case 'upgrader_process_complete' :
|
||||
@@ -413,11 +419,7 @@ function wp_update_themes( $extra_stats = array() ) {
|
||||
$timeout = HOUR_IN_SECONDS;
|
||||
break;
|
||||
default :
|
||||
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
|
||||
$timeout = 0;
|
||||
} else {
|
||||
$timeout = 12 * HOUR_IN_SECONDS;
|
||||
}
|
||||
$timeout = $doing_cron ? 0 : 12 * HOUR_IN_SECONDS;
|
||||
}
|
||||
|
||||
$time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time() - $last_update->last_checked );
|
||||
@@ -463,7 +465,7 @@ function wp_update_themes( $extra_stats = array() ) {
|
||||
$locales = apply_filters( 'themes_update_check_locales', $locales );
|
||||
$locales = array_unique( $locales );
|
||||
|
||||
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
|
||||
if ( $doing_cron ) {
|
||||
$timeout = 30;
|
||||
} else {
|
||||
// Three seconds, plus one extra second for every 10 themes
|
||||
|
||||
Reference in New Issue
Block a user