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

Fixed Deleting a user updates the conversation_recipient user_id to zero

Discussion in 'Resolved Bug Reports' started by Syndol, Jul 17, 2013.

  1. Syndol

    Syndol Guest

    When you delete a user, the xf_conversation_recipient table updates its user_id to zero which is not what you are looking for as per:
    "leaving records in conversation recipient to keep data somewhat intact for others" [DataWriter/User.php -> _postDelete()]

    In Model/User.php you include xf_conversation_recipient in the $userContentChanges array.
    This should not be the case since in DataWriter/User.php in function _postDelete() you call changeContentUser() with a user_id of zero and since that function only checks against a NULL value, the user_id is updated.
  2. Mike

    Mike XenForo Developer Staff Member

    The record is left to ensure that there's an indication that the conversation is with a deleted member compared to deleting the record. Updating it to user_id 0 is the correct behavior though.
  3. Syndol

    Syndol Guest

    I agree that the record should be left intact but you are using update ignore which means the first deleted user is updated to zero while any subsequent users will have their id's left intact.
    Why would would you want to set the id to zero?
  4. Mike

    Mike XenForo Developer Staff Member

    Fair point on the update ignore element. The duplicate data should then be removed.

    But generally speaking, orphaned data that is meant to exist should be changed to user ID 0. We're not actually using foreign keys but it's roughly following that idea.

    I can see where it's not ideal in this case, which is a tricky one because it is actually very important when merging users...
  5. Syndol

    Syndol Guest

    Sorry for keeping you occupied with this but I'm not sure what you mean by he "the duplicate data should then be removed".
    You can only have one user_id with the value of zero in that table yet you want to keep all records.
    The recipient is never counted because they no longer exist in the xf_user table, which is what we want and is regardless of user_id
    How does user merging come into play as they no longer exist?!
    Just trying to understand. Thanks.
  6. Mike

    Mike XenForo Developer Staff Member

    The same code is used for user merging as well.

    I've adjusted this. Queries can be opted out for user deletes (but still be run for merges).
    Syndol likes this.

Share This Page