• 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

S

Syndol

Guest
#1
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.
 

Mike

XenForo developer
Staff member
#2
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.
 
S

Syndol

Guest
#3
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?
 

Mike

XenForo developer
Staff member
#4
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...
 
S

Syndol

Guest
#5
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.
 

Mike

XenForo developer
Staff member
#6
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).