Make WordPress Core

Changeset 49682 for branches/5.6


Ignore:
Timestamp:
11/22/2020 04:04:04 PM (6 years ago)
Author:
SergeyBiryukov
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.
Merges [49677] and [49681] to the 5.6 branch.
Fixes #51827.

Location:
branches/5.6
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.6

  • branches/5.6/src/wp-admin/update-core.php

    r49638 r49682  
    290290        }
    291291
     292        require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     293        $updater = new WP_Automatic_Updater();
     294
    292295        // Defaults:
    293296        $upgrade_dev   = get_site_option( 'auto_update_core_dev', 'enabled' ) === 'enabled';
     
    318321                }
    319322
    320                 // The UI is overridden by the WP_AUTO_UPDATE_CORE constant.
     323                // The UI is overridden by the `WP_AUTO_UPDATE_CORE` constant.
    321324                $can_set_update_option = false;
    322325        }
    323326
    324         if ( defined( 'AUTOMATIC_UPDATER_DISABLED' )
    325                 || has_filter( 'automatic_updater_disabled' )
    326         ) {
    327                 if ( true === AUTOMATIC_UPDATER_DISABLED
    328                         /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
    329                         || true === apply_filters( 'automatic_updater_disabled', false )
    330                 ) {
    331                         $upgrade_dev   = false;
    332                         $upgrade_minor = false;
    333                         $upgrade_major = false;
    334                 }
    335                 // The UI is overridden by the AUTOMATIC_UPDATER_DISABLED constant.
     327        if ( $updater->is_disabled() ) {
     328                $upgrade_dev   = false;
     329                $upgrade_minor = false;
     330                $upgrade_major = false;
     331
     332                /*
     333                 * The UI is overridden by the `AUTOMATIC_UPDATER_DISABLED` constant
     334                 * or the `automatic_updater_disabled` filter,
     335                 * or by `wp_is_file_mod_allowed( 'automatic_updater' )`.
     336                 * See `WP_Automatic_Updater::is_disabled()`.
     337                 */
    336338                $can_set_update_option = false;
    337339        }
    338340
    339         // Is the UI overridden by a plugin using the allow_major_auto_core_updates filter?
     341        // Is the UI overridden by a plugin using the `allow_major_auto_core_updates` filter?
    340342        if ( has_filter( 'allow_major_auto_core_updates' ) ) {
    341343                $can_set_update_option = false;
     
    369371        <p class="auto-update-status">
    370372                <?php
    371                 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    372                 $updater = new WP_Automatic_Updater();
     373
    373374                if ( $updater->is_vcs_checkout( ABSPATH ) ) {
    374375                        _e( 'This site appears to be under version control. Automatic updates are disabled.' );
Note: See TracChangeset for help on using the changeset viewer.