1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed Conversation count incorrect after deleting a user's conversations

Discussion in 'Resolved Bug Reports' started by Jon W, Jul 4, 2015.

  1. Jon W

    Jon W Well-Known Member

    When an administrator deletes a user's conversations through the Admin Control Panel, any user who is in a conversation with that user and who has read that conversation but also has some unread conversations will find that their conversation count is wrong until it is recalculated.

    This happens because the _postDelete method in the ConversationMaster datawriter doesn't actually check whether a conversation has been read and just reduces the unread count by 1 regardless (unless it is already zero).

    The bit of code that causes this is this query:
                UPDATE xf_user AS user
                INNER JOIN xf_conversation_user AS cuser ON
                    (cuser.owner_user_id = user.user_id AND cuser.conversation_id = ?)
                SET user.conversations_unread = user.conversations_unread - 1
                WHERE user.conversations_unread > 0
    I think this can be fixed by simply replacing the line:
    (cuser.owner_user_id user.user_id AND cuser.conversation_id = ?)
    (cuser.owner_user_id user.user_id AND cuser.conversation_id = ? AND cuser.is_unread 1)
    Rob likes this.
  2. Mike

    Mike XenForo Developer Staff Member

    Good catch. Fixed now, thanks. :)
    Jon W likes this.

Share This Page