WordPress.org

Make WordPress Core

Changeset 46276


Ignore:
Timestamp:
09/23/2019 08:51:38 PM (2 months ago)
Author:
SergeyBiryukov
Message:

Site Health: Use WP_Automatic_Updater::is_disabled() to check whether 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-site-health-auto-updates.php

    r46231 r46276  
    2727    public function run_tests() {
    2828        $tests = array(
    29             $this->test_constants( 'DISALLOW_FILE_MODS', false ),
    30             $this->test_constants( 'AUTOMATIC_UPDATER_DISABLED', false ),
    3129            $this->test_constants( 'WP_AUTO_UPDATE_CORE', true ),
    3230            $this->test_wp_version_check_attached(),
    3331            $this->test_filters_automatic_updater_disabled(),
     32            $this->test_wp_automatic_updates_disabled(),
    3433            $this->test_if_failed_update(),
    3534            $this->test_vcs_abspath(),
     
    160159
    161160    /**
     161     * Check if automatic updates are disabled.
     162     *
     163     * @since 5.3.0
     164     *
     165     * @return array|bool The test results. False if auto updates are enabled.
     166     */
     167    public function test_wp_automatic_updates_disabled() {
     168        if ( ! class_exists( 'WP_Automatic_Updater' ) ) {
     169            require_once( ABSPATH . 'wp-admin/includes/class-wp-automatic-updates.php' );
     170        }
     171
     172        $auto_updates = new WP_Automatic_Updater();
     173
     174        if ( ! $auto_updates->is_disabled() ) {
     175            return false;
     176        }
     177
     178        return array(
     179            'description' => __( 'All automatic updates are disabled.' ),
     180            'severity'    => 'fail',
     181        );
     182    }
     183
     184    /**
    162185     * Check if automatic updates have tried to run, but failed, previously.
    163186     *
    164187     * @since 5.2.0
    165188     *
    166      * @return array|bool The test results. false if the auto updates failed.
     189     * @return array|bool The test results. False if the auto updates failed.
    167190     */
    168191    function test_if_failed_update() {
     
    309332     * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
    310333     *
    311      * @return array|bool The test results. false if they're not writeable.
     334     * @return array|bool The test results. False if they're not writeable.
    312335     */
    313336    function test_all_files_writable() {
     
    389412     * @since 5.2.0
    390413     *
    391      * @return array|bool The test results. false if it isn't a development version.
     414     * @return array|bool The test results. False if it isn't a development version.
    392415     */
    393416    function test_accepts_dev_updates() {
Note: See TracChangeset for help on using the changeset viewer.