MDL-65313 core: upgrade code to remove stale favourites for messaging

These were left behing when deleting a group or a course.
This commit is contained in:
Jake Dallimore
2019-05-06 14:11:46 +08:00
parent 6421775ad2
commit 903ec849c5
2 changed files with 17 additions and 1 deletions
+16
View File
@@ -3301,5 +3301,21 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2019042700.01);
}
if ($oldversion < 2019050300.01) {
// Delete all stale favourite records which were left behind when a course was deleted.
$select = 'id IN (
SELECT fav.id as id
FROM {favourite} fav
LEFT JOIN {context} ctx ON (ctx.id = fav.contextid)
WHERE fav.component = :component
AND fav.itemtype = :itemtype
AND ctx.id IS NULL
)';
$params = ['component' => 'core_message', 'itemtype' => 'message_conversations'];
$DB->delete_records_select('favourite', $select, $params);
upgrade_main_savepoint(true, 2019050300.01);
}
return true;
}
+1 -1
View File
@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2019050300.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2019050300.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.