Make WordPress Core

Ticket #20537: 20537-with-filter-refreshed-complete.patch

File 20537-with-filter-refreshed-complete.patch, 2.7 KB (added by jrf, 8 years ago)
  • src/wp-cron.php

    ---
     src/wp-cron.php          | 14 +++++++++++++-
     src/wp-includes/cron.php | 32 ++++++++++++++++++++++++++++++--
     2 files changed, 43 insertions(+), 3 deletions(-)
    
    diff --git a/src/wp-cron.php b/src/wp-cron.php
    index 15c6676..f3625f2 100644
    a b function _get_cron_lock() { 
    5555        return $value;
    5656}
    5757
    58 if ( false === $crons = _get_cron_array() )
     58if ( false === $crons = _get_cron_array() ) {
    5959        die();
     60}
     61
     62$should_skip = false;
     63// Don't process cron for suspended blogs.
     64if ( is_multisite() && ( $current_blog->archived || $current_blog->spam || $current_blog->deleted ) ) {
     65        $should_skip = true;
     66}
     67/** This filter is documented in wp-includes/cron.php */
     68if ( true === apply_filters( 'skip_cron_for_blog', $should_skip, $current_blog ) ) {
     69        return;
     70}
     71unset( $should_skip );
    6072
    6173$keys = array_keys( $crons );
    6274$gmt_time = microtime( true );
  • src/wp-includes/cron.php

    diff --git a/src/wp-includes/cron.php b/src/wp-includes/cron.php
    index 493e0ec..d52b91b 100644
    a b function spawn_cron( $gmt_time = 0 ) { 
    333333 * Run scheduled callbacks or spawn cron for all scheduled events.
    334334 *
    335335 * @since 2.1.0
     336 *
     337 * @global object $current_blog
    336338 */
    337339function wp_cron() {
     340        global $current_blog;
     341
    338342        // Prevent infinite loops caused by lack of wp-cron.php
    339         if ( strpos($_SERVER['REQUEST_URI'], '/wp-cron.php') !== false || ( defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ) )
     343        if ( strpos($_SERVER['REQUEST_URI'], '/wp-cron.php') !== false || ( defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ) ) {
     344                return;
     345        }
     346
     347        if ( false === $crons = _get_cron_array() ) {
    340348                return;
     349        }
    341350
    342         if ( false === $crons = _get_cron_array() )
     351        $should_skip = false;
     352        // Don't process cron for suspended blogs.
     353        if ( is_multisite() && ( $current_blog->archived || $current_blog->spam || $current_blog->deleted ) ) {
     354                $should_skip = true;
     355        }
     356        /**
     357         * Allow to either force skip a cron run or to force cron to run even for suspended blogs.
     358         *
     359         * @since 4.5.0
     360         *
     361         * @param bool        $should_skip  Whether the cron run is going to be skipped.
     362         *                                  Will be `false` for single-site or non-suspended multi-site blogs
     363         *                                  or `true` for suspended blogs.
     364         *                                  Set to `false` to force cron to run or `true` to force cron to quit.
     365         * @param null|object $current_blog The blog object for which cron will run or null if not in
     366         *                                  multi-site.
     367         */
     368        if ( true === apply_filters( 'skip_cron_for_blog', $should_skip, $current_blog ) ) {
    343369                return;
     370        }
     371        unset( $should_skip );
    344372
    345373        $gmt_time = microtime( true );
    346374        $keys = array_keys( $crons );