diff --git a/core/Db/Adapter/Mysqli.php b/core/Db/Adapter/Mysqli.php index 396ab6034309..a5b66e710643 100644 --- a/core/Db/Adapter/Mysqli.php +++ b/core/Db/Adapter/Mysqli.php @@ -71,9 +71,24 @@ public function checkServerVersion() $serverVersion = $this->getServerVersion(); $requiredVersion = Config::getInstance()->General['minimum_mysql_version']; - if (version_compare($serverVersion, $requiredVersion) === -1) { - throw new Exception(Piwik::translate('General_ExceptionDatabaseVersion', array('MySQL', $serverVersion, $requiredVersion))); + if (version_compare($serverVersion, $requiredVersion) >= 0) { + return; } + + // Azure lies/misreports the MySQL version in the connection handshake + if (isset($this->_config['host']) && strpos($this->_config['host'], '.mysql.database.azure.com') !== false) { + $versionInfo = $this->fetchAll('SELECT @@VERSION'); + + if (count($versionInfo)) { + $serverVersion = $versionInfo[0]['@@VERSION']; + + if (version_compare($serverVersion, $requiredVersion) >= 0) { + return; + } + } + } + + throw new Exception(Piwik::translate('General_ExceptionDatabaseVersion', array('MySQL', $serverVersion, $requiredVersion))); } /** diff --git a/core/Db/Adapter/Pdo/Mysql.php b/core/Db/Adapter/Pdo/Mysql.php index 360e6a57e8e0..f7f790661775 100644 --- a/core/Db/Adapter/Pdo/Mysql.php +++ b/core/Db/Adapter/Pdo/Mysql.php @@ -107,9 +107,24 @@ public function checkServerVersion() $serverVersion = $this->getServerVersion(); $requiredVersion = Config::getInstance()->General['minimum_mysql_version']; - if (version_compare($serverVersion, $requiredVersion) === -1) { - throw new Exception(Piwik::translate('General_ExceptionDatabaseVersion', array('MySQL', $serverVersion, $requiredVersion))); + if (version_compare($serverVersion, $requiredVersion) >= 0) { + return; } + + // Azure lies/misreports the MySQL version in the connection handshake + if (isset($this->_config['host']) && strpos($this->_config['host'], '.mysql.database.azure.com') !== false) { + $versionInfo = $this->fetchAll('SELECT @@VERSION'); + + if (count($versionInfo)) { + $serverVersion = $versionInfo[0]['@@VERSION']; + + if (version_compare($serverVersion, $requiredVersion) >= 0) { + return; + } + } + } + + throw new Exception(Piwik::translate('General_ExceptionDatabaseVersion', array('MySQL', $serverVersion, $requiredVersion))); } /**