Opened 6 years ago
Closed 4 years ago
#4170 closed defect (bug) (fixed)
author pages do an uncached user_nicename lookup
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 2.8 |
| Component: | Optimization | Version: | 2.1 |
| Severity: | minor | Keywords: | has-patch tested |
| Cc: |
Description
This isn't an issue until you have a large users table, but these lookups should be cached. Attaching a patch.
Attachments (3)
Change History (15)
comment:4
rob1n
— 6 years ago
- Milestone changed from 2.2 to 2.3
- Owner changed from anonymous to rob1n
comment:6
f00f
— 6 years ago
Looks ok.
I agree with rob1n that the function name should be changed. Furthermore IMHO the cache name should also reflect that user ids are cached, not nicenames. I'd call it user_id_by_nicename or sth. like that.
comment:8
westi
— 5 years ago
- Keywords needs-patch added; has-patch 2nd-opinion removed
- Milestone changed from 2.5 to 2.6
- Owner set to westi
Nice chunky patch that could do with some love as it no longer applies.
Pushing to 2.6 with needs-patch but will possibly accept for 2.5 if patch is updated.
Denis-de-Bernardy
— 4 years ago
comment:9
Denis-de-Bernardy
— 4 years ago
- Component changed from Administration to Optimization
- Keywords has-patch tested added; needs-patch removed
- Milestone changed from 2.9 to 2.8
new patch does the following, against 2.8/trunk:
- add a get_user_by_nicename() function that caches its results
- sets and flushes the cache where appropriate
- uses the function in WP_Query
Denis-de-Bernardy
— 4 years ago
comment:11
ryan
— 4 years ago
Should we pattern after get_term_by() and have one function -- get_user_by() -- for handling retrieving by various fields? Also, I prefer the term "slug" to "nicename". I think it makes it clearer what the field is. So, get_user_by('slug', 'admin');
comment:12
ryan
— 4 years ago
- Resolution set to fixed
- Status changed from new to closed
Shouldn't it be get_user_id_by_nicename()? Since it only returns the ID, as far as I can tell...
To me, get_user_by_nicename() returns an user object with that nicename.