From b3fb605a18b7d2b36a7065391eca2c1f433dde36 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20=C5=A0koda?= <commits@skodak.org>
Date: Wed, 8 Jan 2014 12:09:18 +0800
Subject: [PATCH] MDL-43604 hack around future MariaDB version number mess

---
 lib/dml/mariadb_native_moodle_database.php | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/lib/dml/mariadb_native_moodle_database.php b/lib/dml/mariadb_native_moodle_database.php
index a793a6c..c2e1991 100644
--- a/lib/dml/mariadb_native_moodle_database.php
+++ b/lib/dml/mariadb_native_moodle_database.php
@@ -75,6 +75,20 @@ class mariadb_native_moodle_database extends mysqli_native_moodle_database {
     }
 
     /**
+     * Returns database server info array
+     * @return array Array containing 'description' and 'version' info
+     */
+    public function get_server_info() {
+        $version = $this->mysqli->server_info;
+        if (strpos($version, '5.5.5-10.') === 0 and strpos($version, '-MariaDB') !== false) {
+            // Looks like MariaDB decided to use these weird version numbers for better BC with MySQL...
+            $version = substr($version, 6);
+            $version = str_replace('-MariaDB', '', $version);
+        }
+        return array('description'=>$this->mysqli->server_info, 'version'=>$version);
+    }
+
+    /**
      * It is time to require transactions everywhere.
      *
      * MyISAM is NOT supported!
-- 
1.8.4

