[buddypress-trac] [BuddyPress Trac] #5445: Improve consistency of bp_core_get_user_* use

buddypress-trac noreply at wordpress.org
Mon Mar 3 13:55:39 UTC 2014


#5445: Improve consistency of bp_core_get_user_* use
--------------------------+-----------------
 Reporter:  boonebgorges  |      Owner:
     Type:  enhancement   |     Status:  new
 Priority:  normal        |  Milestone:  2.0
Component:  Core          |    Version:
 Severity:  normal        |   Keywords:
--------------------------+-----------------
 There are a number of generic user-related functions that are used
 frequently throughout BuddyPress: `bp_core_get_user_displayname()`,
 `bp_core_get_user_domain()`, `bp_core_get_core_userdata()`, etc. These
 frequently used functions define what I think of as the "canonical" logic
 for determining the values in question. For example, `_displayname()`
 checks and sets the object cache as necessary; it prefers xprofile data if
 it can be found, followed by display_name and then user_nicename; it
 creates the relevant xprofile fielddata if none is found for that user.
 And so on.

 However, there are many places in BP where we don't use these functions,
 but instead query directly for the data in question. This creates
 inconsistencies in the values displayed, and also makes it very difficult
 to ensure proper caching.

 Let's use this ticket for a few things:
 - Generalizing the functions in question as necessary. In particular, it's
 critical to have the logic abstracted so that we can fetch more than one
 _displaname, _domain, etc with a single database call, while still
 respecting the canonical logic. The simplest way to do this is by creating
 new, plural functions (like `bp_core_get_user_displaynames()`), move most
 of the business logic there, and then turn the singular function into a
 wrapper. I've already done this locally for _displayname(), and it's
 working well.
 - Find places in BP where we are bypassing the canonical functions, and
 refactor to use them. For example, the xprofile component filters
 `bp_user_query_populate_extras` to override the display name. But this
 does not hit the proper caches, nor does it follow the precedence logic of
 the core displayname function. So it should be migrated over. And so on.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/5445>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list