Skip to content

Commit

Permalink
MDL-65313 core: fix deletion of group conversation favourites
Browse files Browse the repository at this point in the history
This now requires itemid, which cannot be null. This is safer. The
context is still used an an additional filter.
  • Loading branch information
snake committed May 7, 2019
1 parent 391d53f commit 151fc53
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions group/lib.php
Expand Up @@ -575,9 +575,10 @@ function groups_delete_group($grouporid) {

// Delete all favourite records for all users relating to this conversation.
// Whilst not ideal, we can't use the component service as it doesn't exist here, so must do this manually.
$params = ['component' => 'core_message', 'itemtype' => 'message_conversations', 'contextid' => $conversation->contextid];
$DB->delete_records_select('favourite', ' component = :component AND itemtype = :itemtype AND contextid = :contextid',
$params);
$params = ['component' => 'core_message', 'itemtype' => 'message_conversations', 'itemid' => $conversation->id,
'contextid' => $conversation->contextid];
$select = ' component = :component AND itemtype = :itemtype AND itemid = :itemid AND contextid = :contextid';
$DB->delete_records_select('favourite', $select, $params);
}

//group itself last
Expand Down

0 comments on commit 151fc53

Please sign in to comment.