From 1d5c40048a7a74c82c658e938f36ad482999ecd1 Mon Sep 17 00:00:00 2001
From: stronk7 <stronk7>
Date: Sat, 13 Jan 2007 10:44:58 +0000
Subject: [PATCH] Moving set_dbfamily() from dmllib.php to setuplib.php as it's
 needed in early stages and we don't want the installer to depend of dmllib.

---
 install.php      |  1 -
 lib/dmllib.php   | 44 --------------------------------------------
 lib/setuplib.php | 44 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 44 insertions(+), 45 deletions(-)

diff --git a/install.php b/install.php
index a1ac5f7c2c..c7109d83bb 100644
--- a/install.php
+++ b/install.php
@@ -125,7 +125,6 @@ require_once('./lib/adminlib.php');
 require_once('./lib/setuplib.php');
 require_once('./lib/moodlelib.php');
 require_once('./lib/weblib.php');
-require_once('./lib/dmllib.php');
 require_once('./lib/deprecatedlib.php');
 require_once('./lib/adodb/adodb.inc.php');
 require_once('./lib/environmentlib.php');
diff --git a/lib/dmllib.php b/lib/dmllib.php
index d8669915f6..38ae9ba47d 100644
--- a/lib/dmllib.php
+++ b/lib/dmllib.php
@@ -1821,50 +1821,6 @@ function configure_dbconnection() {
     set_dbfamily();
 }
 
-/**
- * This internal function sets and returns the proper value for $CFG->dbfamily based on $CFG->dbtype
- * It's called by configure_dbconnection() and at install time. Shouldn't be used
- * in other places. Code should rely on dbfamily to perform conditional execution
- * instead of using dbtype directly. This allows quicker adoption of different
- * drivers going against the same DB backend.
- *
- * This function must contain the init code needed for each dbtype supported.
- *
- * return string dbfamily value (mysql, postgres, oracle, mssql)
- */
-function set_dbfamily() {
-
-    global $CFG, $INSTALL;
-
-    // Since this function is also used during installation process, i.e. during install.php before $CFG->dbtype is set.
-    // we need to get dbtype from the right variable 
-    if (!empty($INSTALL['dbtype'])) {
-        $dbtype = $INSTALL['dbtype'];
-    } else {
-        $dbtype = $CFG->dbtype;
-    }
-
-    switch ($dbtype) {
-        case 'mysql':
-        case 'mysqli':
-            $CFG->dbfamily='mysql';
-            break;
-        case 'postgres7':
-            $CFG->dbfamily='postgres';
-            break;
-        case 'mssql':
-        case 'mssql_n':
-        case 'odbc_mssql':
-            $CFG->dbfamily='mssql';
-            break;
-        case 'oci8po':
-            $CFG->dbfamily='oracle';
-            break;
-    }
-
-    return $CFG->dbfamily;
-}
-
 /**
  * This function will handle all the records before being inserted/updated to DB for Oracle
  * installations. This is because the "special feature" of Oracle where the empty string is
diff --git a/lib/setuplib.php b/lib/setuplib.php
index 788bfad9b1..d564d0d340 100644
--- a/lib/setuplib.php
+++ b/lib/setuplib.php
@@ -202,6 +202,50 @@ function setup_is_unicodedb() {
     return $unicodedb;
 }
 
+/**
+ * This internal function sets and returns the proper value for $CFG->dbfamily based on $CFG->dbtype
+ * It's called by configure_dbconnection() and at install time. Shouldn't be used
+ * in other places. Code should rely on dbfamily to perform conditional execution
+ * instead of using dbtype directly. This allows quicker adoption of different
+ * drivers going against the same DB backend.
+ *
+ * This function must contain the init code needed for each dbtype supported.
+ *
+ * return string dbfamily value (mysql, postgres, oracle, mssql)
+ */
+function set_dbfamily() {
+
+    global $CFG, $INSTALL;
+
+    // Since this function is also used during installation process, i.e. during install.php before $CFG->dbtype is set.
+    // we need to get dbtype from the right variable 
+    if (!empty($INSTALL['dbtype'])) {
+        $dbtype = $INSTALL['dbtype'];
+    } else {
+        $dbtype = $CFG->dbtype;
+    }
+
+    switch ($dbtype) {
+        case 'mysql':
+        case 'mysqli':
+            $CFG->dbfamily='mysql';
+            break;
+        case 'postgres7':
+            $CFG->dbfamily='postgres';
+            break;
+        case 'mssql':
+        case 'mssql_n':
+        case 'odbc_mssql':
+            $CFG->dbfamily='mssql';
+            break;
+        case 'oci8po':
+            $CFG->dbfamily='oracle';
+            break;
+    }
+
+    return $CFG->dbfamily;
+}
+
 function init_memcached() {
     global $CFG, $MCACHE;
 
-- 
2.39.5