diff --git a/htdocs/init.php b/htdocs/init.php index 338572f2c3297014907199425bec7e26587e89b5..85c602d2806bbadb7a265d79db9e5d68101fc0b8 100644 --- a/htdocs/init.php +++ b/htdocs/init.php @@ -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(); diff --git a/htdocs/lang/en.utf8/error.php b/htdocs/lang/en.utf8/error.php index ffa1ad7ca13d0600c75dd68faa7e4312f1e32a73..f022464a36d98914a5c304009b751d5ca78bdc6c 100644 --- a/htdocs/lang/en.utf8/error.php +++ b/htdocs/lang/en.utf8/error.php @@ -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)"; diff --git a/htdocs/lib/adodb/drivers/adodb-postgres64.inc.php b/htdocs/lib/adodb/drivers/adodb-postgres64.inc.php index 9ca6e772c77a854fd8081034d50b3752f433e208..c5b1950af4b97b075c3f0b9077c4c1deb1f86d55 100644 --- a/htdocs/lib/adodb/drivers/adodb-postgres64.inc.php +++ b/htdocs/lib/adodb/drivers/adodb-postgres64.inc.php @@ -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; }