]> git.mjollnir.org Git - moodle.git/commitdiff
Now get_config() is executed after "set names", so textual data retrieved
authorstronk7 <stronk7>
Fri, 7 Apr 2006 23:57:38 +0000 (23:57 +0000)
committerstronk7 <stronk7>
Fri, 7 Apr 2006 23:57:38 +0000 (23:57 +0000)
from the config table has the proper encoding. Bug 5043.
(http://moodle.org/bugs/bug.php?op=show&bugid=5043)

lib/setup.php

index ff4cb99dbd67032c916f10ce72b6770c1cc4000d..07004aea8b6616e7d0a58de7a429a60981c9a8f8 100644 (file)
@@ -180,6 +180,29 @@ global $HTTPSPAGEREQUIRED;
     raise_memory_limit('64M');    // We should never NEED this much but just in case...
 
 
+/// Try to get unicodedb status from DB
+/// (this is the only one transaction executed before "set names")
+    $utftmp = get_config('', 'unicodedb');
+    if ($utftmp !== false) {  //Only if the record exists
+        $CFG->unicodedb = $utftmp->value;
+    }
+/// If $CFG->unicodedb is not set, calculate it because we need
+/// to know to "set names" properly.
+    if (!isset($CFG->unicodedb)) {
+        $CFG->unicodedb = setup_is_unicodedb();
+    }
+/// Set the client/server and connection to utf8 if necessary
+    if ($CFG->unicodedb) {
+        if ($db->databaseType == 'mysql') {
+            $db->Execute("SET NAMES 'utf8'");
+        } else if ($db->databaseType == 'postgres7') {
+            $db->Execute("SET NAMES 'utf8'");
+        }
+    }
+/// Now that "set names" has been executed it is safe to
+/// work with the DB, but never before this!
+
+
 /// Load up any configuration from the config table
     $CFG = get_config();
 
@@ -196,26 +219,6 @@ global $HTTPSPAGEREQUIRED;
     error_reporting($CFG->debug);
 
 
-/// If $CFG->unicodedb is not set, calculate it because we need
-/// "set names" (below) properly executed *before* performing any
-/// DB transaction
-    if ($dbconnected && !isset($CFG->unicodedb)) {
-        $CFG->unicodedb = setup_is_unicodedb();
-    }
-
-
-/// Set the client/server and connection to utf8 if necessary
-    if ($dbconnected && $CFG->unicodedb) {
-        if ($db->databaseType == 'mysql') {
-            $db->Execute("SET NAMES 'utf8'");
-        } else if ($db->databaseType == 'postgres7') {
-            $db->Execute("SET NAMES 'utf8'");
-        }
-    }
-/// Now that "set names" has been executed it is safe to
-/// work with the DB, but never before this!
-
-
 //// Defining the site
     if ($SITE = get_site()) {
         /**