Skip to content
Permalink
Browse files

Site Health: Use `WP_Automatic_Updater::is_disabled()` to check wheth…

…er automatic updates are disabled.

The previous check for `DISALLOW_FILE_MODS` and `AUTOMATIC_UPDATER_DISABLED` constants didn't always provide accurate results.

Props Clorith, kraftner, afragen.
Fixes #47869.

git-svn-id: https://develop.svn.wordpress.org/trunk@46276 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information...
SergeyBiryukov committed Sep 23, 2019
1 parent 1a1d852 commit e4a125425524bc9e8831770c9ef7595306c5fae4
Showing with 28 additions and 5 deletions.
  1. +28 −5 src/wp-admin/includes/class-wp-site-health-auto-updates.php
@@ -26,11 +26,10 @@ public function __construct() {
*/
public function run_tests() {
$tests = array(
$this->test_constants( 'DISALLOW_FILE_MODS', false ),
$this->test_constants( 'AUTOMATIC_UPDATER_DISABLED', false ),
$this->test_constants( 'WP_AUTO_UPDATE_CORE', true ),
$this->test_wp_version_check_attached(),
$this->test_filters_automatic_updater_disabled(),
$this->test_wp_automatic_updates_disabled(),
$this->test_if_failed_update(),
$this->test_vcs_abspath(),
$this->test_check_wp_filesystem_method(),
@@ -158,12 +157,36 @@ public function test_filters_automatic_updater_disabled() {
}
}
/**
* Check if automatic updates are disabled.
*
* @since 5.3.0
*
* @return array|bool The test results. False if auto updates are enabled.
*/
public function test_wp_automatic_updates_disabled() {
if ( ! class_exists( 'WP_Automatic_Updater' ) ) {
require_once( ABSPATH . 'wp-admin/includes/class-wp-automatic-updates.php' );
}
$auto_updates = new WP_Automatic_Updater();
if ( ! $auto_updates->is_disabled() ) {
return false;
}
return array(
'description' => __( 'All automatic updates are disabled.' ),
'severity' => 'fail',
);
}
/**
* Check if automatic updates have tried to run, but failed, previously.
*
* @since 5.2.0
*
* @return array|bool The test results. false if the auto updates failed.
* @return array|bool The test results. False if the auto updates failed.
*/
function test_if_failed_update() {
$failed = get_site_option( 'auto_core_update_failed' );
@@ -308,7 +331,7 @@ function test_check_wp_filesystem_method() {
*
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
*
* @return array|bool The test results. false if they're not writeable.
* @return array|bool The test results. False if they're not writeable.
*/
function test_all_files_writable() {
global $wp_filesystem;
@@ -388,7 +411,7 @@ function test_all_files_writable() {
*
* @since 5.2.0
*
* @return array|bool The test results. false if it isn't a development version.
* @return array|bool The test results. False if it isn't a development version.
*/
function test_accepts_dev_updates() {
include ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z

0 comments on commit e4a1254

Please sign in to comment.
You can’t perform that action at this time.