Make WordPress Core

Opened 17 years ago

Closed 15 years ago

#4170 closed defect (bug) (fixed)

author pages do an uncached user_nicename lookup

Reported by: andy's profile andy Owned by: westi's profile westi
Milestone: 2.8 Priority: normal
Severity: minor Version: 2.1
Component: Optimization Keywords: has-patch tested
Focuses: Cc:


This isn't an issue until you have a large users table, but these lookups should be cached. Attaching a patch.

Attachments (3)

nicename.diff (1.7 KB) - added by andy 17 years ago.
4170.diff (2.7 KB) - added by Denis-de-Bernardy 15 years ago.
4170.2.diff (3.4 KB) - added by Denis-de-Bernardy 15 years ago.

Download all attachments as: .zip

Change History (15)

17 years ago

#1 @Nazgul
17 years ago

  • Keywords has-patch added

#2 @rob1n
17 years ago

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.

#3 @rob1n
17 years ago

  • Keywords 2nd-opinion added

#4 @rob1n
17 years ago

  • Milestone changed from 2.2 to 2.3
  • Owner changed from anonymous to rob1n

#5 @andy
17 years ago

Sure, whatever you want to call it.

#6 @f00f
17 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.

#7 @rob1n
16 years ago

  • Owner rob1n deleted

#8 @westi
16 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.

#9 @Denis-de-Bernardy
15 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

#11 @ryan
15 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');

#12 @ryan
15 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [10992]) Cache user lookups made by nicename. Add get_user_by(). fixes #4170

Note: See TracTickets for help on using tickets.