Make WordPress Core

Changeset 54069


Ignore:
Timestamp:
09/05/2022 03:18:13 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Site Health: Bump the recommended MySQL and MariaDB versions.

  • MySQL 5.6 has reached EOL (“End of Life”) in February 2021. The recommended minimum is bumped to 5.7 for now.
  • MariaDB 10.2 has reached EOL in May 2022. The recommended minimum is bumped to 10.3 for now.

This commit brings the Site Health recommendations in line with readme.html.

Includes:

  • Adding two unit tests to ensure the SQL server versions recommended by Site Health match readme.html.
  • Consistently declaring the recommended and required versions as the WP_Site_Health class properties.
  • Renaming some pre-existing private properties for clarity.

Follow-up to [44986], [52319], [52358], [52420], [52424], [53431], [53433], [53435], [meta11407], [meta11866].

See #55791, #meta5999, #meta6322.

Location:
trunk
Files:
2 edited

Legend:

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

    r54065 r54069  
    1111    private static $instance = null;
    1212
    13     private $mysql_min_version_check;
    14     private $mysql_rec_version_check;
    15 
    16     public $is_mariadb                           = false;
    17     private $mysql_server_version                = '';
    18     private $health_check_mysql_required_version = '5.5';
    19     private $health_check_mysql_rec_version      = '';
     13    private $is_acceptable_mysql_version;
     14    private $is_recommended_mysql_version;
     15
     16    public $is_mariadb                   = false;
     17    private $mysql_server_version        = '';
     18    private $mysql_required_version      = '5.5';
     19    private $mysql_recommended_version   = '5.7';
     20    private $mariadb_recommended_version = '10.3';
    2021
    2122    public $php_memory_limit;
     
    210211        $this->mysql_server_version = $wpdb->get_var( 'SELECT VERSION()' );
    211212
    212         $this->health_check_mysql_rec_version = '5.6';
    213 
    214213        if ( stristr( $mysql_server_type, 'mariadb' ) ) {
    215             $this->is_mariadb                     = true;
    216             $this->health_check_mysql_rec_version = '10.0';
    217         }
    218 
    219         $this->mysql_min_version_check = version_compare( '5.5', $this->mysql_server_version, '<=' );
    220         $this->mysql_rec_version_check = version_compare( $this->health_check_mysql_rec_version, $this->mysql_server_version, '<=' );
     214            $this->is_mariadb                = true;
     215            $this->mysql_recommended_version = $this->mariadb_recommended_version;
     216        }
     217
     218        $this->is_acceptable_mysql_version  = version_compare( $this->mysql_required_version, $this->mysql_server_version, '<=' );
     219        $this->is_recommended_mysql_version = version_compare( $this->mysql_recommended_version, $this->mysql_server_version, '<=' );
    221220    }
    222221
     
    11981197        $db_dropin = file_exists( WP_CONTENT_DIR . '/db.php' );
    11991198
    1200         if ( ! $this->mysql_rec_version_check ) {
     1199        if ( ! $this->is_recommended_mysql_version ) {
    12011200            $result['status'] = 'recommended';
    12021201
     
    12091208                    __( 'For optimal performance and security reasons, you should consider running %1$s version %2$s or higher. Contact your web hosting company to correct this.' ),
    12101209                    ( $this->is_mariadb ? 'MariaDB' : 'MySQL' ),
    1211                     $this->health_check_mysql_rec_version
     1210                    $this->mysql_recommended_version
    12121211                )
    12131212            );
    12141213        }
    12151214
    1216         if ( ! $this->mysql_min_version_check ) {
     1215        if ( ! $this->is_acceptable_mysql_version ) {
    12171216            $result['status'] = 'critical';
    12181217
     
    12261225                    __( 'WordPress requires %1$s version %2$s or higher. Contact your web hosting company to correct this.' ),
    12271226                    ( $this->is_mariadb ? 'MariaDB' : 'MySQL' ),
    1228                     $this->health_check_mysql_required_version
     1227                    $this->mysql_required_version
    12291228                )
    12301229            );
  • trunk/tests/phpunit/tests/site-health.php

    r54053 r54069  
    1010        // Include the `WP_Site_Health` file.
    1111        require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php';
     12    }
     13
     14    /**
     15     * @ticket 55791
     16     * @covers ::prepare_sql_data()
     17     * @covers ::get_test_sql_server()
     18     */
     19    public function test_mysql_recommended_version_matches_readme_html() {
     20        // This test is designed to only run on trunk.
     21        $this->skipOnAutomatedBranches();
     22
     23        $wp_site_health = new WP_Site_Health();
     24        $wp_site_health->get_test_sql_server();
     25
     26        $reflection          = new ReflectionClass( $wp_site_health );
     27        $reflection_property = $reflection->getProperty( 'mysql_recommended_version' );
     28        $reflection_property->setAccessible( true );
     29
     30        $readme = file_get_contents( ABSPATH . 'readme.html' );
     31
     32        preg_match( '#Recommendations.*MySQL</a> version <strong>([0-9.]*)#s', $readme, $matches );
     33
     34        $this->assertSame( $matches[1], $reflection_property->getValue( $wp_site_health ) );
     35    }
     36
     37    /**
     38     * @ticket 55791
     39     * @covers ::prepare_sql_data()
     40     * @covers ::get_test_sql_server()
     41     */
     42    public function test_mariadb_recommended_version_matches_readme_html() {
     43        // This test is designed to only run on trunk.
     44        $this->skipOnAutomatedBranches();
     45
     46        $wp_site_health = new WP_Site_Health();
     47        $wp_site_health->get_test_sql_server();
     48
     49        $reflection          = new ReflectionClass( $wp_site_health );
     50        $reflection_property = $reflection->getProperty( 'mariadb_recommended_version' );
     51        $reflection_property->setAccessible( true );
     52
     53        $readme = file_get_contents( ABSPATH . 'readme.html' );
     54
     55        preg_match( '#Recommendations.*MariaDB</a> version <strong>([0-9.]*)#s', $readme, $matches );
     56
     57        $this->assertSame( $matches[1], $reflection_property->getValue( $wp_site_health ) );
    1258    }
    1359
Note: See TracChangeset for help on using the changeset viewer.