mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
enrol/database tidyup: cleanup mysql hack if connect errors out
This commit is contained in:
parent
3e353d3622
commit
92ab8e50d4
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user