From f711e0b82b055bc47bc1301fa2140664b12d194e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 26 Sep 2023 15:45:41 +0200 Subject: [PATCH] Correctly update the participant counter when removing an invisible participant --- .../lib/data/conversation/ConversationEditor.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/files/lib/data/conversation/ConversationEditor.class.php b/files/lib/data/conversation/ConversationEditor.class.php index 1c98e78..ce1d7f9 100644 --- a/files/lib/data/conversation/ConversationEditor.class.php +++ b/files/lib/data/conversation/ConversationEditor.class.php @@ -170,13 +170,13 @@ class ConversationEditor extends DatabaseObjectEditor */ public function removeParticipant($userID) { - $sql = "SELECT joinedAt + $sql = "SELECT joinedAt, isInvisible FROM wcf1_conversation_to_user WHERE conversationID = ? AND participantID = ?"; $statement = WCF::getDB()->prepare($sql, 1); $statement->execute([$this->conversationID, $userID]); - $joinedAt = $statement->fetchSingleColumn(); + $participantData = $statement->fetchSingleRow(); $sql = "SELECT messageID FROM wcf1_conversation_message @@ -187,7 +187,7 @@ class ConversationEditor extends DatabaseObjectEditor $statement = WCF::getDB()->prepare($sql, 1); $statement->execute([ $this->conversationID, - $joinedAt, + $participantData['joinedAt'], TIME_NOW, ]); $lastMessageID = $statement->fetchSingleColumn(); @@ -207,8 +207,8 @@ class ConversationEditor extends DatabaseObjectEditor $userID, ]); - // decrease participant count unless it is the author - if ($userID != $this->userID) { + // The author and invisible participants are not included in the count. + if ($userID != $this->userID && !$participantData['isInvisible']) { $this->updateCounters([ 'participants' => -1, ]); -- 2.20.1