Make WordPress Core


Ignore:
Timestamp:
11/22/2020 01:01:46 PM (3 years ago)
Author:
azaozz
Message:

Upgrade/Install: Replace the conditionals that check the AUTOMATIC_UPDATER_DISABLED constant and the automatic_updater_disabled filter in update-core.php with a call to WP_Automatic_Updater::is_disabled(). This prevents a PHP warning, fixes the logic, and considers wp_is_file_mod_allowed( 'automatic_updater' ) when determining the UI state.

Props jamesros161, pbiron, audrasjb, azaozz.
Fixes #51827.

File:
1 edited

Legend:

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

    r49668 r49677  
    292292    }
    293293
     294    require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     295    $updater = new WP_Automatic_Updater();
     296
    294297    // Defaults:
    295298    $upgrade_dev   = get_site_option( 'auto_update_core_dev', 'enabled' ) === 'enabled';
     
    324327    }
    325328
    326     if ( defined( 'AUTOMATIC_UPDATER_DISABLED' )
    327         || has_filter( 'automatic_updater_disabled' )
    328     ) {
    329         if ( true === AUTOMATIC_UPDATER_DISABLED
    330             /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
    331             || true === apply_filters( 'automatic_updater_disabled', false )
    332         ) {
    333             $upgrade_dev   = false;
    334             $upgrade_minor = false;
    335             $upgrade_major = false;
    336         }
    337         // The UI is overridden by the AUTOMATIC_UPDATER_DISABLED constant.
     329    if ( $updater->is_disabled() ) {
     330        $upgrade_dev   = false;
     331        $upgrade_minor = false;
     332        $upgrade_major = false;
     333
     334        // The UI is overridden by the AUTOMATIC_UPDATER_DISABLED constant
     335        // or the automatic_updater_disabled filter,
     336        // or by wp_is_file_mod_allowed( 'automatic_updater' ).
     337        // See WP_Automatic_Updater::is_disabled().
    338338        $can_set_update_option = false;
    339339    }
     
    371371    <p class="auto-update-status">
    372372        <?php
    373         require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    374         $updater = new WP_Automatic_Updater();
     373
    375374        if ( $updater->is_vcs_checkout( ABSPATH ) ) {
    376375            _e( 'This site appears to be under version control. Automatic updates are disabled.' );
Note: See TracChangeset for help on using the changeset viewer.