WordPress.org

Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#3716 closed defect (bug) (fixed)

Duplicate cached user information

Reported by: matt Owned by: charleshooper
Milestone: 2.2 Priority: normal
Severity: normal Version:
Component: Optimization Keywords: has-patch
Focuses: Cc:

Description

We cache all of a user's data (their profile and all usermeta) in both the users group keyed by ID, and in the userlogins group keyed by user login name. We're storing 2x more than we should.

Probably userlogins should just be a userlogin to ID mapping, and then get the data from the users cache group.

Attachments (2)

wp_cache.diff (969 bytes) - added by charleshooper 14 years ago.
Optimization changes to wp caching
wp_cache_2.diff (1.1 KB) - added by charleshooper 14 years ago.
WP cache fix with userlogin validation

Download all attachments as: .zip

Change History (12)

#1 @charleshooper
14 years ago

  • Keywords reporter-feedback added

Where is this "userlogins" group? I was assuming you were referring to the tables wp_usermeta and wp_users, but the only duplicate cached information I can see is the row for the meta_key 'nickname' stored in wp_usermeta and wp_users.user_nicename

I'm trying to follow you here but I need more detailed information. Thanks!

#2 @charleshooper
14 years ago

  • Keywords reporter-feedback removed

I feel pretty sheepish. As soon as I posted that I realized we were talking about the cache and not the Wordpress database. Whoops.

@charleshooper
14 years ago

Optimization changes to wp caching

#3 @charleshooper
14 years ago

  • Keywords has-patch needs-testing added
  • Owner changed from anonymous to charleshooper
  • Status changed from new to assigned

So I dove into the caching class and made the changes I've just attached. My changes seem to work just fine, haven't noticed anything funky, but I'm going to mark this as needs-testing anyhow

#4 @ryan
14 years ago

That looks good. We might need to either use a cache group other than 'userlogins' or somehow invalidate old userlogins cache data.

#5 @charleshooper
14 years ago

I've submitted another patch. (Get rid of the old one before applying this next one.)

Now the 'userlogins' group is checked if it's an object. If it is then that user's cached data is deleted and get_userdatabylogin() carries on as usual.

@charleshooper
14 years ago

WP cache fix with userlogin validation

#6 @ryan
14 years ago

Invalidating during the upgrade where the code run once and then forgotten is better. With this code, it runs every time even though it is only needed one time.

But come to think of it, we flush the cache during upgrade so userlogins should be dumped during upgrade. We just need to bump the DB ver to force an upgrade and cache flush. So, nevermind, your first patch will work. :-)

#7 @charleshooper
14 years ago

  • Keywords needs-testing removed

Hah, alright. I'll keep your comments in mind for future changes.

#8 @charleshooper
14 years ago

  • Owner changed from charleshooper to anonymous
  • Status changed from assigned to new

#9 @charleshooper
14 years ago

  • Owner changed from anonymous to charleshooper
  • Status changed from new to assigned

#10 @ryan
14 years ago

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

(In [4859]) Cache user id instead of full user object in the userlogins cache. Props charleshooper. fixes #3716

Note: See TracTickets for help on using tickets.