Skip to:
Content

BuddyPress.org

Opened 11 years ago

Closed 11 years ago

#5703 closed enhancement (fixed)

friends_check_friendship_status() doesn't check BP_User_Query

Reported by: r-a-y's profile r-a-y Owned by: r-a-y's profile r-a-y
Milestone: 2.1 Priority: normal
Severity: normal Version: 1.7
Component: Friends Keywords: has-patch commit
Cc:

Description

If you're on the members directory and you're logged in, during the members loop, a check is done to see if you are friends with each person in the member loop.

However, when we do this friendship check with friends_check_friendship_status(), we are not referencing the already-queried data from bp_friends_filter_user_query_populate_extras().

As a result, twenty additional DB queries are added on the members directory.

Attached patch removes these queries by:

  • Adding an additional property - friendship_status - to bp_friends_filter_user_query_populate_extras(). This property references the various friendship statuses from BP_Friends_Friendship::check_is_friend().
  • friends_check_friendship_status() now checks for this property during the member loop and avoids any additional DB lookups.

Attachments (2)

5703.01.patch (1.8 KB) - added by r-a-y 11 years ago.
5703.02.patch (5.0 KB) - added by boonebgorges 11 years ago.

Download all attachments as: .zip

Change History (4)

@r-a-y
11 years ago

#1 @boonebgorges
11 years ago

  • Keywords commit added

As a result, twenty additional DB queries are added on the members directory.

Heroic!

5703.02.patch adds unit tests.

#2 @r-a-y
11 years ago

  • Owner set to r-a-y
  • Resolution set to fixed
  • Status changed from new to closed

In 8514:

Check BP_User_Query when using friends_check_friendship_status().

Previously, friends_check_friendship_status() did not reference the data
already queried in the members loop via BP_User_Query. As a result, if
a user was logged in and viewing the member directory, this added twenty
additional DB queries to the page.

This commit:

  • Adds an additional property - friendship_status - to bp_friends_filter_user_query_populate_extras(). This property references the various friendship statuses from BP_Friends_Friendship::check_is_friend()
  • Checks this new property in friends_check_friendship_status() before querying the DB
  • Adds unit tests

Props r-a-y, boonebgorges.

Fixes #5703.

Note: See TracTickets for help on using tickets.