From f677bc838e27fa90204b46c174c33c689d87a250 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 22 Nov 2020 16:06:06 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/branches/5.6@49682 git-svn-id: http://core.svn.wordpress.org/branches/5.6@49405 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/update-core.php | 33 +++++++++++++++++---------------- wp-includes/version.php | 2 +- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/wp-admin/update-core.php b/wp-admin/update-core.php index 47f4b6ae52..5895aad70f 100644 --- a/wp-admin/update-core.php +++ b/wp-admin/update-core.php @@ -289,6 +289,9 @@ function core_auto_updates_settings() { } } + require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; + $updater = new WP_Automatic_Updater(); + // Defaults: $upgrade_dev = get_site_option( 'auto_update_core_dev', 'enabled' ) === 'enabled'; $upgrade_minor = get_site_option( 'auto_update_core_minor', 'enabled' ) === 'enabled'; @@ -317,26 +320,25 @@ function core_auto_updates_settings() { $upgrade_major = false; } - // The UI is overridden by the WP_AUTO_UPDATE_CORE constant. + // The UI is overridden by the `WP_AUTO_UPDATE_CORE` constant. $can_set_update_option = false; } - if ( defined( 'AUTOMATIC_UPDATER_DISABLED' ) - || has_filter( 'automatic_updater_disabled' ) - ) { - if ( true === AUTOMATIC_UPDATER_DISABLED - /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */ - || true === apply_filters( 'automatic_updater_disabled', false ) - ) { - $upgrade_dev = false; - $upgrade_minor = false; - $upgrade_major = false; - } - // The UI is overridden by the AUTOMATIC_UPDATER_DISABLED constant. + if ( $updater->is_disabled() ) { + $upgrade_dev = false; + $upgrade_minor = false; + $upgrade_major = false; + + /* + * The UI is overridden by the `AUTOMATIC_UPDATER_DISABLED` constant + * or the `automatic_updater_disabled` filter, + * or by `wp_is_file_mod_allowed( 'automatic_updater' )`. + * See `WP_Automatic_Updater::is_disabled()`. + */ $can_set_update_option = false; } - // Is the UI overridden by a plugin using the allow_major_auto_core_updates filter? + // Is the UI overridden by a plugin using the `allow_major_auto_core_updates` filter? if ( has_filter( 'allow_major_auto_core_updates' ) ) { $can_set_update_option = false; } @@ -368,8 +370,7 @@ function core_auto_updates_settings() {

is_vcs_checkout( ABSPATH ) ) { _e( 'This site appears to be under version control. Automatic updates are disabled.' ); } elseif ( $upgrade_major ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index a83ea577c9..4ed43d5b65 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.6-RC1-49667'; +$wp_version = '5.6-RC1-49682'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.