From 2b25b67ea11bc2a2377cf2a786ac06c99e2bcedc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Massart?= Date: Tue, 24 Apr 2018 10:38:27 +0800 Subject: [PATCH] MDL-61984 mod_chat: Do not assume context passed is one of chat --- mod/chat/classes/privacy/provider.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mod/chat/classes/privacy/provider.php b/mod/chat/classes/privacy/provider.php index 4d727676442..4cdc875562c 100644 --- a/mod/chat/classes/privacy/provider.php +++ b/mod/chat/classes/privacy/provider.php @@ -167,7 +167,12 @@ class provider implements 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]); -- 2.43.0