MDL-67458 core: removing stale cohortroles and role assignments

This commit is contained in:
Jake Dallimore
2019-12-11 09:38:59 +08:00
parent c309ace4a9
commit 2e9dd5864e
2 changed files with 12 additions and 1 deletions
+11
View File
@@ -3448,5 +3448,16 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2019052002.07);
}
if ($oldversion < 2019052003.05) {
// Delete any tool_cohortroles mappings for roles which no longer exist.
$DB->delete_records_select('tool_cohortroles', "roleid NOT IN (SELECT id FROM {role})");
// Delete any role assignments for roles which no longer exist.
$DB->delete_records_select('role_assignments', "roleid NOT IN (SELECT id FROM {role})");
// Main savepoint reached.
upgrade_main_savepoint(true, 2019052003.05);
}
return true;
}
+1 -1
View File
@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2019052003.04; // 20190520 = branching date YYYYMMDD - do not modify!
$version = 2019052003.05; // 20190520 = branching date YYYYMMDD - do not modify!
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.