From 8e7ca8320e3409705a6f9cbb992bc70d96e623b7 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sun, 22 Nov 2020 13:01:46 +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. Fixes #51827. git-svn-id: https://develop.svn.wordpress.org/trunk@49677 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/update-core.php | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/wp-admin/update-core.php b/src/wp-admin/update-core.php index 3beb87b6ed..c67ac9ace2 100644 --- a/src/wp-admin/update-core.php +++ b/src/wp-admin/update-core.php @@ -291,6 +291,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'; @@ -323,18 +326,15 @@ function core_auto_updates_settings() { $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; } @@ -370,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 ) {