diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 744561c125d..b3e24ea7562 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -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; } diff --git a/version.php b/version.php index a7b5515d297..9dbdfb4b4f6 100644 --- a/version.php +++ b/version.php @@ -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.