From 234d16cfcbfd207459d97881e044cbec900493f9 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Fri, 9 Feb 2018 14:46:11 +0800 Subject: [PATCH] MDL-61375 mod_chat: specify the 'eventtype' to avoid duplicate rows --- mod/chat/lib.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mod/chat/lib.php b/mod/chat/lib.php index d4f50835288..6a442f41e14 100644 --- a/mod/chat/lib.php +++ b/mod/chat/lib.php @@ -160,7 +160,8 @@ function chat_update_instance($chat) { $event = new stdClass(); - if ($event->id = $DB->get_field('event', 'id', array('modulename' => 'chat', 'instance' => $chat->id))) { + if ($event->id = $DB->get_field('event', 'id', array('modulename' => 'chat', + 'instance' => $chat->id, 'eventtype' => CHAT_EVENT_TYPE_CHATTIME))) { if ($chat->schedule > 0) { $event->type = CALENDAR_EVENT_TYPE_ACTION; @@ -494,7 +495,8 @@ function chat_prepare_update_events($chat, $cm = null) { $event->description = format_module_intro('chat', $chat, $cm->id); $event->timestart = $chat->chattime; $event->timesort = $chat->chattime; - if ($event->id = $DB->get_field('event', 'id', array('modulename' => 'chat', 'instance' => $chat->id))) { + if ($event->id = $DB->get_field('event', 'id', array('modulename' => 'chat', 'instance' => $chat->id, + 'eventtype' => CHAT_EVENT_TYPE_CHATTIME))) { $calendarevent = calendar_event::load($event->id); $calendarevent->update($event); } else if ($chat->schedule > 0) {