Commit 4bdafccb authored by Nigel McNie's avatar Nigel McNie

(#2318) Check for Postgres 8.1 or MySQL 5.0.25 as appropriate.

parent 51044d18
......@@ -112,6 +112,20 @@ try {
$dbconnected = $db->Connect($CFG->dbhost,$CFG->dbuser,$CFG->dbpass,$CFG->dbname);
}
// Now we have a connection, verify the server is a new enough version
$dbversion = $db->ServerInfo();
if (is_postgres()) {
$okversion = '8.1';
$dbfriendlyname = 'PostgreSQL';
}
else if (is_mysql()) {
$okversion = '5.0.25';
$dbfriendlyname = 'MySQL';
}
if ($dbversion['version'] < $okversion) {
throw new ConfigSanityException(get_string('dbversioncheckfailed', 'error', $dbfriendlyname, $dbversion['version'], $okversion));
}
$db->SetFetchMode(ADODB_FETCH_ASSOC);
configure_dbconnection();
ensure_internal_plugins_exist();
......@@ -119,6 +133,9 @@ try {
ob_end_clean();
}
catch (Exception $e) {
if ($e instanceof ConfigSanityException) {
throw $e;
}
$errormessage = ob_get_contents();
if (!$errormessage) {
$errormessage = $e->getMessage();
......
......@@ -54,6 +54,7 @@ $string['dbconnfailed'] = 'Mahara could not connect to the application database.
The error received was:
';
$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
$string['blocktypenametaken'] = "Block type %s is already taken by another plugin (%s)";
......
......@@ -123,11 +123,8 @@ WHERE relkind in ('r','v') AND (c.relname='%s' or c.relname = lower('%s'))
function ServerInfo()
{
if (isset($this->version)) return $this->version;
$arr['description'] = $this->GetOne("select version()");
$arr['version'] = ADOConnection::_findvers($arr['description']);
$this->version = $arr;
return $arr;
}
......
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