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)
This commit is contained in:
+23
-20
@@ -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()) {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user