mirror of
git://develop.git.wordpress.org/
synced 2025-02-07 08:04:27 +01:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@54069 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
c7af86080d
commit
604abb0216
@ -10,13 +10,14 @@
|
||||
class WP_Site_Health {
|
||||
private static $instance = null;
|
||||
|
||||
private $mysql_min_version_check;
|
||||
private $mysql_rec_version_check;
|
||||
private $is_acceptable_mysql_version;
|
||||
private $is_recommended_mysql_version;
|
||||
|
||||
public $is_mariadb = false;
|
||||
private $mysql_server_version = '';
|
||||
private $health_check_mysql_required_version = '5.5';
|
||||
private $health_check_mysql_rec_version = '';
|
||||
public $is_mariadb = false;
|
||||
private $mysql_server_version = '';
|
||||
private $mysql_required_version = '5.5';
|
||||
private $mysql_recommended_version = '5.7';
|
||||
private $mariadb_recommended_version = '10.3';
|
||||
|
||||
public $php_memory_limit;
|
||||
|
||||
@ -209,15 +210,13 @@ class WP_Site_Health {
|
||||
|
||||
$this->mysql_server_version = $wpdb->get_var( 'SELECT VERSION()' );
|
||||
|
||||
$this->health_check_mysql_rec_version = '5.6';
|
||||
|
||||
if ( stristr( $mysql_server_type, 'mariadb' ) ) {
|
||||
$this->is_mariadb = true;
|
||||
$this->health_check_mysql_rec_version = '10.0';
|
||||
$this->is_mariadb = true;
|
||||
$this->mysql_recommended_version = $this->mariadb_recommended_version;
|
||||
}
|
||||
|
||||
$this->mysql_min_version_check = version_compare( '5.5', $this->mysql_server_version, '<=' );
|
||||
$this->mysql_rec_version_check = version_compare( $this->health_check_mysql_rec_version, $this->mysql_server_version, '<=' );
|
||||
$this->is_acceptable_mysql_version = version_compare( $this->mysql_required_version, $this->mysql_server_version, '<=' );
|
||||
$this->is_recommended_mysql_version = version_compare( $this->mysql_recommended_version, $this->mysql_server_version, '<=' );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1197,7 +1196,7 @@ class WP_Site_Health {
|
||||
|
||||
$db_dropin = file_exists( WP_CONTENT_DIR . '/db.php' );
|
||||
|
||||
if ( ! $this->mysql_rec_version_check ) {
|
||||
if ( ! $this->is_recommended_mysql_version ) {
|
||||
$result['status'] = 'recommended';
|
||||
|
||||
$result['label'] = __( 'Outdated SQL server' );
|
||||
@ -1208,12 +1207,12 @@ class WP_Site_Health {
|
||||
/* translators: 1: The database engine in use (MySQL or MariaDB). 2: Database server recommended version number. */
|
||||
__( '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.' ),
|
||||
( $this->is_mariadb ? 'MariaDB' : 'MySQL' ),
|
||||
$this->health_check_mysql_rec_version
|
||||
$this->mysql_recommended_version
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! $this->mysql_min_version_check ) {
|
||||
if ( ! $this->is_acceptable_mysql_version ) {
|
||||
$result['status'] = 'critical';
|
||||
|
||||
$result['label'] = __( 'Severely outdated SQL server' );
|
||||
@ -1225,7 +1224,7 @@ class WP_Site_Health {
|
||||
/* translators: 1: The database engine in use (MySQL or MariaDB). 2: Database server minimum version number. */
|
||||
__( 'WordPress requires %1$s version %2$s or higher. Contact your web hosting company to correct this.' ),
|
||||
( $this->is_mariadb ? 'MariaDB' : 'MySQL' ),
|
||||
$this->health_check_mysql_required_version
|
||||
$this->mysql_required_version
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -11,6 +11,52 @@ class Tests_Site_Health extends WP_UnitTestCase {
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 55791
|
||||
* @covers ::prepare_sql_data()
|
||||
* @covers ::get_test_sql_server()
|
||||
*/
|
||||
public function test_mysql_recommended_version_matches_readme_html() {
|
||||
// This test is designed to only run on trunk.
|
||||
$this->skipOnAutomatedBranches();
|
||||
|
||||
$wp_site_health = new WP_Site_Health();
|
||||
$wp_site_health->get_test_sql_server();
|
||||
|
||||
$reflection = new ReflectionClass( $wp_site_health );
|
||||
$reflection_property = $reflection->getProperty( 'mysql_recommended_version' );
|
||||
$reflection_property->setAccessible( true );
|
||||
|
||||
$readme = file_get_contents( ABSPATH . 'readme.html' );
|
||||
|
||||
preg_match( '#Recommendations.*MySQL</a> version <strong>([0-9.]*)#s', $readme, $matches );
|
||||
|
||||
$this->assertSame( $matches[1], $reflection_property->getValue( $wp_site_health ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 55791
|
||||
* @covers ::prepare_sql_data()
|
||||
* @covers ::get_test_sql_server()
|
||||
*/
|
||||
public function test_mariadb_recommended_version_matches_readme_html() {
|
||||
// This test is designed to only run on trunk.
|
||||
$this->skipOnAutomatedBranches();
|
||||
|
||||
$wp_site_health = new WP_Site_Health();
|
||||
$wp_site_health->get_test_sql_server();
|
||||
|
||||
$reflection = new ReflectionClass( $wp_site_health );
|
||||
$reflection_property = $reflection->getProperty( 'mariadb_recommended_version' );
|
||||
$reflection_property->setAccessible( true );
|
||||
|
||||
$readme = file_get_contents( ABSPATH . 'readme.html' );
|
||||
|
||||
preg_match( '#Recommendations.*MariaDB</a> version <strong>([0-9.]*)#s', $readme, $matches );
|
||||
|
||||
$this->assertSame( $matches[1], $reflection_property->getValue( $wp_site_health ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure Site Health reports correctly cron job reports.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user