Skip to content

Commit

Permalink
MDL-61984 mod_chat: Do not assume context passed is one of chat
Browse files Browse the repository at this point in the history
  • Loading branch information
FMCorz authored and andrewnicols committed Apr 24, 2018
1 parent 1dacf61 commit 21f51cf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mod/chat/classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,12 @@ public static function delete_data_for_all_users_in_context(context $context) {
return;
}

$chatid = get_coursemodule_from_id('chat', $context->instanceid, 0, false, MUST_EXIST)->instance;
$cm = get_coursemodule_from_id('chat', $context->instanceid);
if (!$cm) {
return;
}

$chatid = $cm->instance;
$DB->delete_records_select('chat_messages', 'chatid = :chatid', ['chatid' => $chatid]);
$DB->delete_records_select('chat_messages_current', 'chatid = :chatid', ['chatid' => $chatid]);
$DB->delete_records_select('chat_users', 'chatid = :chatid', ['chatid' => $chatid]);
Expand Down

0 comments on commit 21f51cf

Please sign in to comment.