From 965596b4735cb969ae8e68841b4133cc3f3613ce Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Fri, 8 May 2020 13:58:41 +1000 Subject: [PATCH] Set minimum install MySQL version to be 5.5 and a recommended minimum of 5.7 Fix to use min install version --- CRM/Upgrade/Incremental/General.php | 14 ++++++++++++++ CRM/Utils/Check/Component/Env.php | 7 +++++-- Civi/Install/Requirements.php | 2 +- install/index.php | 6 +++--- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/CRM/Upgrade/Incremental/General.php b/CRM/Upgrade/Incremental/General.php index 013bd70b73..3820347d65 100644 --- a/CRM/Upgrade/Incremental/General.php +++ b/CRM/Upgrade/Incremental/General.php @@ -44,6 +44,20 @@ class CRM_Upgrade_Incremental_General { */ const MIN_INSTALL_PHP_VER = '7.1.0'; + /** + * The minimum recommended MySQL/MariaDB version. + * + * A site running an earlier version will be told to upgrade. + */ + const MIN_RECOMMENDED_MYSQL_VER = '5.7'; + + /** + * The minimum MySQL/MariaDB version required to install Civi. + * + * @see install/index.php + */ + const MIN_INSTALL_MYSQL_VER = '5.5'; + /** * Compute any messages which should be displayed before upgrade. * diff --git a/CRM/Utils/Check/Component/Env.php b/CRM/Utils/Check/Component/Env.php index 7051ed56a0..8cc07c6e95 100644 --- a/CRM/Utils/Check/Component/Env.php +++ b/CRM/Utils/Check/Component/Env.php @@ -938,12 +938,14 @@ class CRM_Utils_Check_Component_Env extends CRM_Utils_Check_Component { public function checkMysqlVersion() { $messages = []; $version = CRM_Utils_SQL::getDatabaseVersion(); - if (version_compare(CRM_Utils_SQL::getDatabaseVersion(), '5.7', '<')) { + $minInstallVersion = CRM_Upgrade_Incremental_General::MIN_INSTALL_MYSQL_VER; + $minRecommendedVersion = CRM_Upgrade_Incremental_General::MIN_RECOMMENDED_MYSQL_VER; + if (version_compare(CRM_Utils_SQL::getDatabaseVersion(), $minInstallVersion, '<')) { $messages[] = new CRM_Utils_Check_Message( __FUNCTION__, ts('This system uses MySQL/MariaDB version %1. To ensure the continued operation of CiviCRM, upgrade your server now. At least MySQL version %2 or MariaDB version %3 is recommended', [ 1 => $version, - 2 => '5.7', + 2 => $minRecommendedVersion, 3 => '10.1', ]), ts('MySQL Out of date'), @@ -951,6 +953,7 @@ class CRM_Utils_Check_Component_Env extends CRM_Utils_Check_Component { 'fa-server' ); } + return $messages; } } diff --git a/Civi/Install/Requirements.php b/Civi/Install/Requirements.php index 63b6cb0552..4e94c8568c 100644 --- a/Civi/Install/Requirements.php +++ b/Civi/Install/Requirements.php @@ -291,7 +291,7 @@ class Requirements { * @return array */ public function checkMysqlVersion(array $db_config) { - $min = '5.1'; + $min = CRM_Upgrade_Incremental_General::MIN_INSTALL_MYSQL_VER; $results = [ 'title' => 'CiviCRM MySQL Version', 'severity' => $this::REQUIREMENT_OK, diff --git a/install/index.php b/install/index.php index 49cf011ca4..c0e66c03b0 100644 --- a/install/index.php +++ b/install/index.php @@ -480,11 +480,11 @@ class InstallRequirements { ) ) ) { - @$this->requireMySQLVersion("5.1", + @$this->requireMySQLVersion(CRM_Upgrade_Incremental_General::MIN_INSTALL_MYSQL_VER, array( ts("MySQL %1 Configuration", array(1 => $dbName)), - ts("MySQL version at least %1", array(1 => '5.1')), - ts("MySQL version %1 or higher is required, you are running MySQL %2.", array(1 => '5.1', 2 => mysqli_get_server_info($this->conn))), + ts("MySQL version at least %1", array(1 => CRM_Upgrade_Incremental_General::MIN_INSTALL_MYSQL_VER)), + ts("MySQL version %1 or higher is required, you are running MySQL %2.", array(1 => CRM_Upgrade_Incremental_General::MIN_INSTALL_MYSQL_VER, 2 => mysqli_get_server_info($this->conn))), ts("MySQL %1", array(1 => mysqli_get_server_info($this->conn))), ) ); -- 2.25.1