Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

mnet MDL-17629 upgrade to fix referntial integrity in mnet hostids fo…

…r localhost and all hosts records
  • Loading branch information...
commit 70d2f4be3cce27278fa699fcb34a145516d5e1eb 1 parent bcaa8cd
Penny Leach authored
Showing with 24 additions and 1 deletion.
  1. +5 −0 lib/db/upgrade.php
  2. +18 −0 lib/db/upgradelib.php
  3. +1 −1  version.php
View
5 lib/db/upgrade.php
@@ -3314,6 +3314,11 @@ function xmldb_main_upgrade($oldversion=0) {
upgrade_main_savepoint($result, 2007101571.01);
}
+ if ($result && $oldversion < 2007101571.02) {
+ upgrade_fix_incorrect_mnethostids();
+ upgrade_main_savepoint($result, 2007101571.02);
+ }
+
return $result;
}
View
18 lib/db/upgradelib.php
@@ -607,6 +607,17 @@ function upgrade_fix_incorrect_mnethostids() {
$current_mnet_localhost_host = get_record('mnet_host', 'wwwroot', addslashes($CFG->wwwroot)); /// By wwwroot
$current_mnet_all_hosts_host = get_record_select('mnet_host', sql_isempty('mnet_host', 'wwwroot', false, false)); /// By empty wwwroot
+ if (!$moodleapplicationid = get_field('mnet_application', 'id', 'name', 'moodle')) {
+ $m = (object)array(
+ 'name' => 'moodle',
+ 'display_name' => 'Moodle',
+ 'xmlrpc_server_url' => '/mnet/xmlrpc/server.php',
+ 'sso_land_url' => '/auth/mnet/land.php',
+ 'sso_jump_url' => '/auth/mnet/land.php',
+ );
+ $moodleapplicationid = insert_record('mnet_application', $m);
+ }
+
/// Create localhost_host if necessary (pretty improbable but better to be 100% in the safe side)
/// Code stolen from mnet_environment->init
if (!$current_mnet_localhost_host) {
@@ -619,6 +630,7 @@ function upgrade_fix_incorrect_mnethostids() {
$current_mnet_localhost_host->last_log_id = 0;
$current_mnet_localhost_host->deleted = 0;
$current_mnet_localhost_host->name = '';
+ $current_mnet_localhost_host->applicationid = $moodleapplicationid;
/// Get the ip of the server
if (empty($_SERVER['SERVER_ADDR'])) {
/// SERVER_ADDR is only returned by Apache-like webservers
@@ -648,6 +660,7 @@ function upgrade_fix_incorrect_mnethostids() {
$current_mnet_all_hosts_host->last_log_id = 0;
$current_mnet_all_hosts_host->deleted = 0;
$current_mnet_all_hosts_host->name = 'All Hosts';
+ $current_mnet_all_hosts_host->applicationid = $moodleapplicationid;
$current_mnet_all_hosts_host->id = insert_record('mnet_host', $current_mnet_all_hosts_host, true);
}
@@ -689,6 +702,11 @@ function upgrade_fix_incorrect_mnethostids() {
set_field('user', 'mnethostid', $current_mnet_localhost_host->id, 'id', $rec->id);
}
rs_close($rs);
+
+ // fix up any host records that have incorrect ids
+ set_field_select('mnet_host', 'applicationid', $moodleapplicationid, "id = $current_mnet_localhost_host->id or id = $current_mnet_all_hosts_host->id");
+
+
}
?>
View
2  version.php
@@ -6,7 +6,7 @@
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
- $version = 2007101571.01; // YYYYMMDD = date of the 1.9 branch (don't change)
+ $version = 2007101571.02; // YYYYMMDD = date of the 1.9 branch (don't change)
// X = release number 1.9.[0,1,2,3,4,5...]
// Y.YY = micro-increments between releases
Please sign in to comment.
Something went wrong with that request. Please try again.