From 1dd74afe9e035200b75955d9e7366f6091055b31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0koda?= Date: Tue, 11 Mar 2014 09:07:21 +0800 Subject: [PATCH] MDL-43604 add support for future hacky MariaDB versions This patch also shows the real server version without normalisation on the environment page, this should hopefully help people to identify MariaDB... --- lib/dml/mariadb_native_moodle_database.php | 14 ++++++++++++++ lib/environmentlib.php | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/dml/mariadb_native_moodle_database.php b/lib/dml/mariadb_native_moodle_database.php index a793a6ce1fc..cbf5992200f 100644 --- a/lib/dml/mariadb_native_moodle_database.php +++ b/lib/dml/mariadb_native_moodle_database.php @@ -74,6 +74,20 @@ class mariadb_native_moodle_database extends mysqli_native_moodle_database { return 'mariadb'; } + /** + * Returns database server info array + * @return array Array containing 'description' and 'version' info + */ + public function get_server_info() { + $version = $this->mysqli->server_info; + $matches = null; + if (preg_match('/^5\.5\.5-(10\..+)-MariaDB$/i', $version, $matches)) { + // Looks like MariaDB decided to use these weird version numbers for better BC with MySQL... + $version = $matches[1]; + } + return array('description'=>$this->mysqli->server_info, 'version'=>$version); + } + /** * It is time to require transactions everywhere. * diff --git a/lib/environmentlib.php b/lib/environmentlib.php index f4e168103d7..987190d729c 100644 --- a/lib/environmentlib.php +++ b/lib/environmentlib.php @@ -984,7 +984,7 @@ function environment_check_database($version, $env_select) { $result->setLevel($level); $result->setCurrentVersion($current_version); $result->setNeededVersion($needed_version); - $result->setInfo($current_vendor); + $result->setInfo($current_vendor . ' (' . $dbinfo['description'] . ')'); /// Do any actions defined in the XML file. process_environment_result($vendorsxml[$current_vendor], $result);