WordPress.org

Make WordPress Core

Changeset 42584


Ignore:
Timestamp:
01/24/2018 04:16:18 AM (5 months ago)
Author:
dd32
Message:

Updates: Only trigger Background Update processes from within the core update check when a core autoupdate is on offer.

This change reduces the number of API calls which WordPress makes to api.wordpress.org during release windows.

Previously the background updates would run upon every core update transient refresh, however now they'll only run if there's an update available.
The change also increases the cache period for plugin & theme checks when running via the cron, from never-cache to 2 hours, which should hopefully reduce the number of needless API calls.

Fixes #43103 for trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/update.php

    r42343 r42584  
    174174    }
    175175
    176     $offers = $body['offers'];
     176    $offers          = $body['offers'];
     177    $has_auto_update = false;
    177178
    178179    foreach ( $offers as &$offer ) {
     
    208209            )
    209210        );
     211
     212        if ( 'autoupdate' == $offer->response ) {
     213            $has_auto_update = true;
     214        }
    210215    }
    211216
     
    230235
    231236    // Trigger background updates if running non-interactively, and we weren't called from the update handler.
    232     if ( $doing_cron && ! doing_action( 'wp_maybe_auto_update' ) ) {
    233         do_action( 'wp_maybe_auto_update' );
     237    if ( $doing_cron && $has_auto_update && ! doing_action( 'wp_maybe_auto_update' ) ) {
     238        include_once( ABSPATH . '/wp-admin/includes/update.php' );
     239
     240        // Only trigger background updates if an acceptable autoupdate is on offer, avoids needless extra API calls.
     241        if ( find_core_auto_update() ) {
     242            do_action( 'wp_maybe_auto_update' );
     243        }
    234244    }
    235245}
     
    288298        default:
    289299            if ( $doing_cron ) {
    290                 $timeout = 0;
     300                $timeout = 2 * HOUR_IN_SECONDS;
    291301            } else {
    292302                $timeout = 12 * HOUR_IN_SECONDS;
     
    475485            break;
    476486        default:
    477             $timeout = $doing_cron ? 0 : 12 * HOUR_IN_SECONDS;
     487            if ( $doing_cron ) {
     488                $timeout = 2 * HOUR_IN_SECONDS;
     489            } else {
     490                $timeout = 12 * HOUR_IN_SECONDS;
     491            }
    478492    }
    479493
Note: See TracChangeset for help on using the changeset viewer.