Commit 43f67d3b authored by Nigel McNie's avatar Nigel McNie

Enforce check for UTF8 database upon installation.

Now Mahara will actually crash and burn if the database isn't UTF8, rather than just bitching about it.

It's time we put an end to the madness.
parent 43303646
......@@ -71,10 +71,6 @@ $coresuccess = json_encode(get_string('coredatasuccess', 'admin'));
if (!empty($upgrades['core']->install)) {
$upgrades['firstcoredata'] = true;
$upgrades['lastcoredata'] = true;
if (!db_is_utf8()) {
global $SESSION;
$SESSION->add_info_msg(get_string('databasenotutf8', 'admin'));
}
$smarty->assign('install', true);
}
......
......@@ -252,11 +252,14 @@ if (get_config('siteclosed')) {
// check to see if we're installed...
$scriptfilename = str_replace('\\', '/', $_SERVER['SCRIPT_FILENAME']);
if (!get_config('installed')
&& false === strpos($scriptfilename, 'admin/index.php')
if (!get_config('installed')) {
ensure_install_sanity();
if (false === strpos($scriptfilename, 'admin/index.php')
&& false === strpos($scriptfilename, 'admin/upgrade.php')
&& false === strpos($scriptfilename, 'admin/upgrade.json.php')) {
redirect('/admin/');
redirect('/admin/');
}
}
if (defined('JSON') && !defined('NOSESSKEY')) {
......
......@@ -37,7 +37,6 @@ $string['component'] = 'Component or plugin';
$string['continue'] = 'Continue';
$string['coredata'] = 'core data';
$string['coredatasuccess'] = 'Successfully installed core data';
$string['databasenotutf8'] = 'You are not using a UTF-8 database. UTF-8 is the recommended character encoding for Mahara.';
$string['fromversion'] = 'From version';
$string['information'] = 'Information';
$string['installsuccess'] = 'Successfully installed version ';
......
......@@ -56,6 +56,7 @@ $string['dbconnfailed'] = 'Mahara could not connect to the application database.
The error received was:
';
$string['dbnotutf8'] = 'You are not using a UTF-8 database. Mahara stores all data as UTF-8 internally. Please drop and re-create your database using UTF-8 encoding.';
$string['dbversioncheckfailed'] = 'Your database server version is not new enough to successfully run Mahara. Your server is %s %s, but Mahara requires at least version %s.';
// general exception error messages
......
......@@ -156,6 +156,17 @@ function ensure_sanity() {
raise_memory_limit('32M');
}
/**
* Check sanity of things that we only check at installation time - not on
* every request, like ensure_sanity() does
*/
function ensure_install_sanity() {
// Must must must be a UTF8 database!
if (!db_is_utf8()) {
throw new ConfigSanityException(get_string('dbnotutf8', 'error'));
}
}
/**
* Check to see if the internal plugins are installed. Die if they are not.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment