mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
During installation, if the database isn't UTF and it is empty,
then try and set it to UTF automatically. I did MySQL only, can someone tackle this for PostgreSQL?
This commit is contained in:
parent
b5a5d9f668
commit
b1e64385dc
1 changed files with 22 additions and 6 deletions
20
install.php
20
install.php
|
@ -294,13 +294,29 @@ if ($INSTALL['stage'] == DATABASE) {
|
||||||
if ($rs && $rs->RecordCount() > 0) {
|
if ($rs && $rs->RecordCount() > 0) {
|
||||||
$records = $rs->GetAssoc(true);
|
$records = $rs->GetAssoc(true);
|
||||||
$encoding = $records['character_set_database']['Value'];
|
$encoding = $records['character_set_database']['Value'];
|
||||||
if (strtoupper($encoding) != 'UTF8') {
|
if (strtoupper($encoding) == 'UTF8') {
|
||||||
|
$INSTALL['dbencodingtestresults'] = true;
|
||||||
|
} else {
|
||||||
|
// Try to set the encoding now!
|
||||||
|
if (! $db->Metatables()) { // We have no tables so go ahead
|
||||||
|
$db->Execute("ALTER DATABASE `".$INSTALL['dbname']."` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci");
|
||||||
|
$rs = $db->Execute("SHOW VARIABLES LIKE 'character_set_database'"); // this works
|
||||||
|
|
||||||
|
$records = $rs->GetAssoc(true);
|
||||||
|
$encoding = $records['character_set_database']['Value'];
|
||||||
|
|
||||||
|
if (strtoupper($encoding) == 'UTF8') {
|
||||||
|
$INSTALL['dbencodingtestresults'] = true;
|
||||||
|
} else {
|
||||||
$errormsg = get_string('dbwrongencoding', 'install', $encoding);
|
$errormsg = get_string('dbwrongencoding', 'install', $encoding);
|
||||||
$nextstage = DATABASE;
|
$nextstage = DATABASE;
|
||||||
$INSTALL['showskipdbencodingtest'] = true;
|
$INSTALL['showskipdbencodingtest'] = true;
|
||||||
$INSTALL['dbencodingtestresults'] = false;
|
$INSTALL['dbencodingtestresults'] = false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$INSTALL['dbencodingtestresults'] = true;
|
$INSTALL['showskipdbencodingtest'] = true;
|
||||||
|
$INSTALL['dbencodingtestresults'] = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue