N°1728: Display error on setup for unsupported MySQL 8+ versions (MariaDB & Percona not affected)

This commit is contained in:
Stephen Abello
2018-11-14 10:12:36 +01:00
parent 17589e060a
commit b898a09c4c
2 changed files with 46 additions and 7 deletions

View File

@@ -108,6 +108,10 @@ class MySQLHasGoneAwayException extends MySQLException
*/
class CMDBSource
{
const ENUM_DB_VENDOR_MYSQL = 'MySQL';
const ENUM_DB_VENDOR_MARIADB = 'MariaDB';
const ENUM_DB_VENDOR_PERCONA = 'Percona';
protected static $m_sDBHost;
protected static $m_sDBUser;
protected static $m_sDBPwd;
@@ -406,6 +410,27 @@ class CMDBSource
return $aVersions[0];
}
/**
* Get the DB vendor between MySQL and its main forks
* @return string
*/
static public function GetDBVendor()
{
$sDBVendor = static::ENUM_DB_VENDOR_MYSQL;
$sVersionComment = strtolower(static::GetServerVariable('version_comment'));
if(preg_match('/mariadb/', $sVersionComment) === 1)
{
$sDBVendor = static::ENUM_DB_VENDOR_MARIADB;
}
else if(preg_match('/percona/', $sVersionComment) === 1)
{
$sDBVendor = static::ENUM_DB_VENDOR_PERCONA;
}
return $sDBVendor;
}
/**
* @param string $sSource
*

View File

@@ -52,6 +52,8 @@ class SetupUtils
// -- Minimum versions (requirements : forbids installation if not met)
const PHP_MIN_VERSION = '5.6.0'; // 5.6 will be supported until the end of 2018 (see http://php.net/supported-versions.php)
const MYSQL_MIN_VERSION = '5.6.0'; // 5.6 to have fulltext on InnoDB for Tags fields (N°931)
const MYSQL_NOT_VALIDATED_VERSION = '8.0.0'; //Mysql 8 not validated as of iTop 2.6
// -- versions that will be the minimum in next iTop major release (warning if not met)
const PHP_NEXT_MIN_VERSION = ''; // no new PHP requirement for next iTop version
const MYSQL_NEXT_MIN_VERSION = ''; // no new MySQL requirement for next iTop version
@@ -1215,10 +1217,19 @@ EOF
*
* @return boolean false if DB doesn't meet the minimum version requirement
*/
private static function CheckDbServerVersion(&$aResult, $oDBSource)
static private function CheckDbServerVersion(&$aResult, $oDBSource)
{
$sDBVendor= $oDBSource->GetDBVendor();
$sDBVersion = $oDBSource->GetDBVersion();
if (version_compare($sDBVersion, self::MYSQL_MIN_VERSION, '>='))
$bRet = false;
if (version_compare($sDBVersion, self::MYSQL_NOT_VALIDATED_VERSION, '>=') && ($sDBVendor === CMDBSource::ENUM_DB_VENDOR_MYSQL))
{
$aResult['checks'][] = new CheckResult(CheckResult::ERROR,
"Error: Current MySQL version is $sDBVersion. iTop doesn't yet support MySQL ".self::MYSQL_NOT_VALIDATED_VERSION." and above.");
$bRet = false;
}
else if (version_compare($sDBVersion, self::MYSQL_MIN_VERSION, '>='))
{
$aResult['checks'][] = new CheckResult(CheckResult::INFO,
"Current MySQL version ($sDBVersion), greater than minimum required version (".self::MYSQL_MIN_VERSION.")");
@@ -1238,13 +1249,16 @@ EOF
}
}
return true;
$bRet = true;
}
else
{
$aResult['checks'][] = new CheckResult(CheckResult::ERROR,
"Error: Current MySQL version is $sDBVersion, minimum required version is ".self::MYSQL_MIN_VERSION);
$bRet = false;
}
$aResult['checks'][] = new CheckResult(CheckResult::ERROR,
"Error: Current MySQL version is $sDBVersion, minimum required version is ".self::MYSQL_MIN_VERSION);
return false;
return $bRet;
}
/**