“Bug” in adding friends: Multiple Friend Requests from Same Person
I have a rare, but still occuring case that sometimes two persons in my BP network have multiple friendship rows in the DB, both more or less entered at the same second.
I’m not entirely sure how to reproduce this. Probably some JS problem, or maybe a partially loaded page and reclicking the button. Anyway, JS error caused the Add Friend button to not be greyed out and each request sent using the button showed up as a dupe friend request.
Interesting thing is: They cannot confirm their friendship, because – I mean they can confirm the first entry. But the second entry will still show is_confirmed=0 and cannot be confirmed anymore because BP_Friends_Friendship::accept() only updates the row which is already is_confirmed=1, but the other row with is_confirmed=0 still shows the pending friendship request.
To fix this for future friendships, I was wondering why not just entering a UNIQUE index over those fields?
UNIQUE(initiator_user_id, friend_user_id, is_confirmed)
This would be a constrait, which would help in case somehow the AJAX to insert a friendship row gets triggered twice.
What do you think?
- You must be logged in to reply to this topic.