bug with friends feature leaving orphan entry in database

Permalink
I was testing my site and ran into a problem with the friends feature that I am wondering about (I couldn't find anything in the bug list). I had two users where one was a friend of the other. I deleted one of the users and it left an orphan entry in the usersFriends table. This caused an exception "Call to member function on non-object" error later when attempting to click on "Friends" link in the profile. I got past the problem by deleting the orphan entry but now I'm trying to decide what to tell my client. It's a nice feature so I don't want to tell them it doesn't work and to avoid it. I will try to see if I can figure out a patch but I'm wondering how stable the friends feature is. Any comments? Anyone else come up with a fix? Thanks.

 
dg1 replied on at Permalink Reply
I added the following code to models/userinfo.php in the delete() method where all the sql calls are made to delete entries and it seems to work:

/* FIX for orphan entries in UsersFriends when a user id deleted */
                        $r = $db->query("DELETE FROM UsersFriends WHERE uID = ?",array(intval($this->uID)) );
                        $r = $db->query("DELETE FROM UsersFriends WHERE friendUID = ?",array(intval($this->uID)) );
                        /* END OF FIX */


If there are any issues with this or if I have misunderstood something, please let me know.
Thanks.
goldfish replied on at Permalink Reply
goldfish
This is an issue in 5.4.1.1 as well. When you delete a user, anyone who has friended that user will see an error on their friends page. This would be a good patch to add to the core.