MDL-38314 repository: Remove orphan repository instances

This commit is contained in:
Frederic Massart 2013-06-04 15:56:25 +08:00
parent f0d37f4ac5
commit 4aa4d88da8
2 changed files with 15 additions and 1 deletions

View file

@ -2190,5 +2190,19 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2013061700.00); upgrade_main_savepoint(true, 2013061700.00);
} }
if ($oldversion < 2013062700.01) {
// Remove orphan repository instances.
$sql = 'SELECT contextid FROM {repository_instances} ri
WHERE NOT EXISTS (
SELECT id FROM {context} c
WHERE c.id = ri.contextid)';
$ids = $DB->get_fieldset_sql($sql);
$DB->delete_records_list('repository_instances', 'contextid', $ids);
// Main savepoint reached.
upgrade_main_savepoint(true, 2013062700.01);
}
return true; return true;
} }

View file

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$version = 2013062700.00; // YYYYMMDD = weekly release date of this DEV branch $version = 2013062700.01; // YYYYMMDD = weekly release date of this DEV branch
// RR = release increments - 00 in DEV branches // RR = release increments - 00 in DEV branches
// .XX = incremental changes // .XX = incremental changes