Skip to content

Commit

Permalink
Merge pull request #3814 from meeting-room-booking-system/3805-upgrad…
Browse files Browse the repository at this point in the history
…ing-doesnt-work-in-multisite-mode-if-the-sub-sites-do-not-all-use-the-same-database

3805 upgrading doesnt work in multisite mode if the sub sites do not all use the same database
  • Loading branch information
campbell-m authored Jan 24, 2025
2 parents cb14fd9 + 2fa878e commit 523090d
Show file tree
Hide file tree
Showing 7 changed files with 297 additions and 152 deletions.
7 changes: 7 additions & 0 deletions web/css/mrbs.css.php
Original file line number Diff line number Diff line change
Expand Up @@ -2504,6 +2504,13 @@
}


/* ------------- UPGRADE.INC -------------*/

.upgrade_nav {
margin-top: 3em;
}


/* ------------ VIEW_ENTRY.PHP ------------------*/

.view_entry #entry td:first-child,
Expand Down
20 changes: 18 additions & 2 deletions web/dbsys.inc
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,24 @@ function db()
}
catch (\Exception $e)
{
$db_obj = DBFactory::create($dbsys, $db_host, $db_login, $db_password,
$db_database, (bool) $db_persist, $db_port, $db_options);
try
{
$db_obj = DBFactory::create(
$dbsys,
$db_host,
$db_login,
$db_password,
$db_database,
(bool)$db_persist,
$db_port,
$db_options
);
}
catch (\Exception $e)
{
trigger_error($e->getMessage(), E_USER_WARNING);
fatal_error(get_vocab('fatal_db_error'));
}
}

return $db_obj;
Expand Down
14 changes: 9 additions & 5 deletions web/lang/lang.en
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,17 @@ $vocab["contact_admin"] = "If you are not the MRBS administrator plea
$vocab["upgrading_site"] = "Upgrading site '%s'"; // site name
$vocab["upgrading_main_site"] = "Upgrading the main site";
$vocab["no_tables_found"] = "No tables found";
$vocab["already_at_version"] = "Already at version %d.";
$vocab["mrbs_upgrade_needed"] = "A later version of MRBS is required to run against this version of the database tables.";
$vocab["upgrade_to_version"] = "Upgrading to database version";
$vocab["upgrade_to_local_version"] = "Upgrading to database local version";
$vocab["upgrade_completed"] = "Database upgrade completed.";
$vocab["no_handles_main_site"] = "A database connection could not be established in order to upgrade the main site.";
$vocab["no_handles_sub_sites"] = "A database connection could not be established in order to upgrade the following sub-sites:";
$vocab["retry_from_failing"] = "Please launch MRBS from one of the failing sites and, when prompted, enter the " .
"credentials for the database associated with that site.";
$vocab["upgrade_summary"] = "Upgrade summary";
$vocab["upgrade_completed"] = "Database upgrade successfully completed.";
$vocab["no_connection"] = "A database connection could not be established.";
$vocab["main_site_failed"] = "The main site could not be upgraded.";
$vocab["failed_sites"] = "The following sub-sites could not be upgraded:";
$vocab["retry_from_failing"] = "If a database connection could not be established for a site, please launch MRBS " .
"from that site and, when prompted, enter the database credentials for that site.";

// User access levels
$vocab["level_0"] = "none";
Expand Down
7 changes: 0 additions & 7 deletions web/lib/MRBS/DB.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,6 @@ protected function connect(
}


// Output our own message to avoid giving away the database credentials
protected function connectError(string $message): void
{
trigger_error($message, E_USER_WARNING);
fatal_error(get_vocab('fatal_db_error'));
}

//
public function error(): string
{
Expand Down
2 changes: 1 addition & 1 deletion web/lib/MRBS/DB_mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function __construct(
}
else
{
$this->connectError($message);
throw new DBException($message);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion web/lib/MRBS/DB_pgsql.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function __construct(
{
$message .= ".\n[MRBS note] Try setting " . '$db_host' . " to '127.0.0.1'.";
}
$this->connectError($message);
throw new DBException($message);
}
}

Expand Down
Loading

0 comments on commit 523090d

Please sign in to comment.