Skip to:
Content

BuddyPress.org

Opened 10 years ago

Closed 6 years ago

#5457 closed enhancement (maybelater)

Improvements to friends_get_friend_user_ids()

Reported by: r-a-y's profile r-a-y Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Friends Keywords: needs-patch, trac-tidy-2018
Cc:

Description

The friends_get_friend_user_ids() function gets the user IDs that a user is friends with.

There are two extra parameters - $friend_requests_only and $assoc_arr.

If $friend_requests_only is set to true, only user IDs that initiated the friendship request are returned. However, currently this grabs pending friendships (is_confirmed = 0). It would be useful if we could also grab confirmed friendships as well by omitting the is_confirmed = 0 clause.

If $assoc_arr is set to true, then an associated array like:

array(
	array( 'user_id' => x ),
	array( 'user_id' => x ),
)

is returned. This isn't very useful and isn't used within the internal codebase of BuddyPress. I also checked the WP.org repo and no plugin appears to be using this functionality.

Therefore, the attached patch removes the $assoc_arr argument and replaces it with $get_all, which allows us to grab all friendships regardless of pending or confirmed status.

Attached patch also changes how user IDs are fetched. If $friend_requests_only is set to true, we only need to select the initiator_user_id column and avoids having to select two columns and do a foreach loop.

Wanted to get something up on Trac before I forget to post about it.

Attachments (1)

5457.01.patch (7.3 KB) - added by r-a-y 10 years ago.

Download all attachments as: .zip

Change History (8)

@r-a-y
10 years ago

#1 @boonebgorges
10 years ago

Thanks for doing due diligence on whether the $assoc_arr argument is used anywhere. However, even though you didn't find any instances of its being used in public, I'd wager that someone somewhere is using it for some odd reason. Since it's trivial to maintain backward compatibility in this case (by shifting $get_all to the fourth param slot), let's do it. Throw a _deprecated_argument() notice if you'd like.

The other changes look good to me. Feel free to commit the tests for existing functionality before you do the rest of the patch.

(Side note - in the long run, it'd be nice to migrate these one-offs to central query classes. Maybe a BP_Friend_Query extends BP_User_Query. Caching etc become much easier. But that's an issue for another ticket.)

#2 @DJPaul
10 years ago

  • Keywords early added
  • Milestone changed from Awaiting Review to 2.1

#3 @DJPaul
10 years ago

  • Keywords needs-patch added; has-patch early removed

Needs a refreshed patch in the next couple of weeks to get into 2.1.

#4 @DJPaul
10 years ago

  • Milestone changed from 2.1 to 2.2

#5 @DJPaul
9 years ago

  • Milestone changed from 2.2 to Future Release

#6 @DJPaul
6 years ago

  • Keywords trac-tidy-2018 added

We're closing this ticket because it has not received any contribution or comments for at least two years. We have decided that it is better to close tickets that are good ideas, which have not gotten (or are unlikely to get) contributions, rather than keep things open indefinitely. This will help us share a more realistic roadmap for BuddyPress with you.

Everyone very much appreciates the time and effort that you spent sharing your idea with us. On behalf of the entire BuddyPress team, thank you.

If you feel strongly that this enhancement should still be added to BuddyPress, and you are able to contribute effort towards it, we encourage you to re-open the ticket, or start a discussion about it in our Slack channel. Please consider that time has proven that good ideas without contributions do not get built.

For more information, see https://bpdevel.wordpress.com/2018/01/21/our-awaiting-contributions-milestone-contains/
or find us on Slack, in the #buddypress channel: https://make.wordpress.org/chat/

#7 @DJPaul
6 years ago

  • Milestone Awaiting Contributions deleted
  • Resolution set to maybelater
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.