From: Tim Düsterhus Date: Tue, 26 Sep 2023 13:45:41 +0000 (+0200) Subject: Correctly update the participant counter when removing an invisible participant X-Git-Tag: 5.5.18~3^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f711e0b82b055bc47bc1301fa2140664b12d194e;p=GitHub%2FWoltLab%2Fcom.woltlab.wcf.conversation.git Correctly update the participant counter when removing an invisible participant --- 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, ]);