From 8685db91b86f980c78166587afc6bacba1404d96 Mon Sep 17 00:00:00 2001 From: Anthon Pang Date: Mon, 23 Apr 2018 18:58:50 -0400 Subject: [PATCH] Fixes #12002 and #12030 - azure fallback to "select @@version" (#12551) * Fixes #12002 and #12030 - azure fallback to "select @@version" * Add comment for why @@VERSION is used instead of going through the connection object. --- core/Db/Adapter/Mysqli.php | 18 ++++++++++++++++++ core/Db/Adapter/Pdo/Mysql.php | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/core/Db/Adapter/Mysqli.php b/core/Db/Adapter/Mysqli.php index 4c8c7fed813..f8fe9a0d3c7 100644 --- a/core/Db/Adapter/Mysqli.php +++ b/core/Db/Adapter/Mysqli.php @@ -98,6 +98,24 @@ public function checkServerVersion() } } + /** + * Returns the MySQL server version + * + * @return null|string + */ + public function getServerVersion() + { + // prioritizing SELECT @@VERSION in case the connection version string is incorrect (which can + // occur on Azure) + $versionInfo = $this->fetchAll('SELECT @@VERSION'); + + if (count($versionInfo)) { + return $versionInfo[0]['@@VERSION']; + } + + return parent::getServerVersion(); + } + /** * Check client version compatibility against database server * diff --git a/core/Db/Adapter/Pdo/Mysql.php b/core/Db/Adapter/Pdo/Mysql.php index b9b250081f9..b45d718c5a5 100644 --- a/core/Db/Adapter/Pdo/Mysql.php +++ b/core/Db/Adapter/Pdo/Mysql.php @@ -134,6 +134,24 @@ public function checkServerVersion() } } + /** + * Returns the MySQL server version + * + * @return null|string + */ + public function getServerVersion() + { + // prioritizing SELECT @@VERSION in case the connection version string is incorrect (which can + // occur on Azure) + $versionInfo = $this->fetchAll('SELECT @@VERSION'); + + if (count($versionInfo)) { + return $versionInfo[0]['@@VERSION']; + } + + return parent::getServerVersion(); + } + /** * Check client version compatibility against database server *