diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 0bd812003ff..bf1cb78ce4b 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -2172,5 +2172,19 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2013051400.06); } + if ($oldversion < 2013051400.09) { + + // 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, 2013051400.09); + } + return true; } diff --git a/version.php b/version.php index 394c58e80bd..be062dd964c 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2013051400.08; // 20130514 = branching date YYYYMMDD - do not modify! +$version = 2013051400.09; // 20130514 = branching date YYYYMMDD - do not modify! // RR = release increments - 00 in DEV branches // .XX = incremental changes