enrol/database tidyup: cleanup mysql hack if connect errors out

This commit is contained in:
martinlanghoff 2006-01-16 03:04:31 +00:00
parent 3e353d3622
commit 92ab8e50d4

View File

@ -204,6 +204,11 @@ function enrol_connect() {
if ($enroldb->PConnect($CFG->enrol_dbhost,$CFG->enrol_dbuser,$CFG->enrol_dbpass,$CFG->enrol_dbname)) {
return $enroldb;
} else {
// do a bit of cleanup, and lot the problem
if (!empty($CFG->prefix_old)) {
$CFG->prefix =$CFG->prefix_old; // Restore it just in case
unset($CFG->prefix_old);
}
trigger_error("Error connecting to enrolment DB backend with: "
. "$CFG->enrol_dbhost,$CFG->enrol_dbuser,$CFG->enrol_dbpass,$CFG->enrol_dbname");
return false;
@ -216,6 +221,8 @@ function enrol_disconnect($enroldb) {
$enroldb->Close();
// Cleanup the mysql
// hack
if (!empty($CFG->prefix_old)) {
$CFG->prefix =$CFG->prefix_old; // Restore it just in case
unset($CFG->prefix_old);