When trying to add a friend which has already been added as a friend by another user (and that request was approved), then my request does not show up in the "Awaiting friend approvals" list.
I tracked down the problem to the join in the view, between flag_friend and the users table. It misses a condition to limit the flag_friends to the user who requests the friendship (flag_friend.uid).
SELECT DISTINCT(users.uid) AS uid,
users.picture AS users_picture,
users.name AS users_name,
users.mail AS users_mail,
flag_content_users__flag_friend_message.message AS flag_content_users__flag_friend_message_message,
flag_content.content_id AS flag_content_content_id
FROM users users
INNER JOIN flag_content flag_content_users ON users.uid = flag_content_users.content_id AND flag_content_users.fid = 4
LEFT JOIN flag_friend flag_friend_users ON users.uid = flag_friend_users.friend_uid AND flag_friend_users.fid = 4
LEFT JOIN flag_friend_message flag_content_users__flag_friend_message ON flag_content_users.fcid = flag_content_users__flag_friend_message.fcid
LEFT JOIN flag_content flag_content ON users.uid = flag_content.content_id AND (flag_content.fid = 4 AND flag_content.uid = 84 AND flag_content.sid = 0)
WHERE (users.status <> 0) AND (flag_friend_users.fid IS NULL) AND (flag_content_users.uid = 84)
GROUP BY uid
should have an additional condition on the first LEFT JOIN, matching the flag_friend.uid with the argument provided to the view:
SELECT DISTINCT(users.uid) AS uid,
users.picture AS users_picture,
users.name AS users_name,
users.mail AS users_mail,
flag_content_users__flag_friend_message.message AS flag_content_users__flag_friend_message_message,
flag_content.content_id AS flag_content_content_id
FROM users users
INNER JOIN flag_content flag_content_users ON users.uid = flag_content_users.content_id AND flag_content_users.fid = 4
LEFT JOIN flag_friend flag_friend_users ON users.uid = flag_friend_users.friend_uid AND flag_friend_users.fid = 4 AND flag_friend_users.uid=84
LEFT JOIN flag_friend_message flag_content_users__flag_friend_message ON flag_content_users.fcid = flag_content_users__flag_friend_message.fcid
LEFT JOIN flag_content flag_content ON users.uid = flag_content.content_id AND (flag_content.fid = 4 AND flag_content.uid = 84 AND flag_content.sid = 0)
WHERE (users.status <> 0) AND (flag_friend_users.fid IS NULL) AND (flag_content_users.uid = 84)
GROUP BY uid
Without this condition, the flag_friend entries of other requesters are joined, so it will seem like the request was approved already.
I expect the "Friend requests" page to have a similar issue, but I did not yet track down the exact changes required to make it work correctly.
Comments
Comment #1
cyberwolf commentedAs a temporary fix, I now alter the query by implementing hook_views_query_alter() in my own module:
Comment #2
joecanti commentedGetting the same issue here i think - although I just cannot add more than one friend to any user.
Subscribing,
Joe
Comment #3
braindrift commentedSame here,
the snippet from #1 fixes this issue (also the issue from #2).
Comment #4
dreamdust commentedI can confirm the snippet from #1 fixes the issue.
Comment #5
sirkitree commentedThe 6.x-2.x-dev version of this module is pretty abandoned. Is this report valid for the 1.x version (which isn't abandoned)?
Comment #6
sirkitree commentedwrong status
Comment #7
sirkitree commentedClosing due to inactivity.