From 6ed15ea50a708977fc5716a7840383eaeb45a547 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Fri, 7 Apr 2006 23:57:38 +0000 Subject: [PATCH] Now get_config() is executed after "set names", so textual data retrieved from the config table has the proper encoding. Bug 5043. (http://moodle.org/bugs/bug.php?op=show&bugid=5043) --- lib/setup.php | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/lib/setup.php b/lib/setup.php index ff4cb99dbd..07004aea8b 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -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()) { /** -- 2.39.5