Opened 11 years ago
Closed 11 years ago
#5445 closed enhancement (fixed)
Improve consistency of bp_core_get_user_* use
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 2.0 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Core | Keywords: | |
Cc: |
Description
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.
In 8024: