From 83efbc67e3e0aa66eb1bd0aff98b6df0504832b0 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 28 Aug 2019 03:07:59 +0000 Subject: [PATCH] Site Health: Standardize on `SELECT VERSION()` query for checking the database server version, due to the MariaDB version declaration potentially causing issues in production environments. Partially reverts [45691]. Props Clorith. Fixes #47738. git-svn-id: https://develop.svn.wordpress.org/trunk@45904 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-debug-data.php | 2 +- src/wp-admin/includes/class-wp-site-health.php | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/wp-admin/includes/class-wp-debug-data.php b/src/wp-admin/includes/class-wp-debug-data.php index 674ea4b464..f3ecdca9f2 100644 --- a/src/wp-admin/includes/class-wp-debug-data.php +++ b/src/wp-admin/includes/class-wp-debug-data.php @@ -719,7 +719,7 @@ class WP_Debug_Data { $extension = null; } - $server = $wpdb->db_version(); + $server = $wpdb->get_var( 'SELECT VERSION()' ); if ( isset( $wpdb->use_mysqli ) && $wpdb->use_mysqli ) { $client_version = $wpdb->dbh->client_info; diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index 01f97959c5..c759effd83 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -132,18 +132,16 @@ class WP_Site_Health { private function prepare_sql_data() { global $wpdb; - if ( method_exists( $wpdb, 'db_version' ) ) { - if ( $wpdb->use_mysqli ) { - // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysqli_get_server_info - $mysql_server_type = mysqli_get_server_info( $wpdb->dbh ); - } else { - // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysql_get_server_info - $mysql_server_type = mysql_get_server_info( $wpdb->dbh ); - } - - $this->mysql_server_version = $wpdb->db_version(); + if ( $wpdb->use_mysqli ) { + // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysqli_get_server_info + $mysql_server_type = mysqli_get_server_info( $wpdb->dbh ); + } else { + // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysql_get_server_info + $mysql_server_type = mysql_get_server_info( $wpdb->dbh ); } + $this->mysql_server_version = $wpdb->get_var( 'SELECT VERSION()' ); + $this->health_check_mysql_rec_version = '5.6'; if ( stristr( $mysql_server_type, 'mariadb' ) ) {