Make WordPress Core

Opened 7 years ago

Last modified 3 months ago

#43393 assigned defect (bug)

get_user_by can return wrong user info

Reported by: hberberoglu's profile hberberoglu Owned by: pbearne's profile pbearne
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Users Keywords:
Focuses: performance Cc:

Description

I am using memcached object cache dropin (I use https://tr.wordpress.org/plugins/memcached/) and there is two user record on wp_users table; one user's user_login is 'AlbertEinstein' other one's is 'Albert Einstein'. So there is two different user.

But these codes below are returning always same user's info; AlbertEinstein's info.

$user_data = get_user_by('login', 'Albert Einstein');
$user_data = get_user_by('login', 'AlbertEinstein');

It happens because of memcached protocol;

For installs that use the memcache/memcached object-cache drop-in (and possibly others), the resulting wp_cache_get always returns false since a memcached key "... must not include control characters or whitespace." (per https://github.com/memcached/memcached/blob/master/doc/protocol.txt)

(this copied from #39034)

Change History (3)

#1 @ocean90
7 years ago

  • Version 4.9.4 deleted

This is actually a bug in the drop-in caused by this line:
return preg_replace('/\s+/', '', WP_CACHE_KEY_SALT . "$prefix$group:$key"); .

Using a placeholder in cache keys rather than simply stripping out spaces would solve this.

#2 @hberberoglu
7 years ago

@ocean90 thanks for fast response. I agree with you and to solve this I'll do a code change on drop-in side. I do not know how WordPress's approach is in such cases.

If you say; the drop-in should solve this, then okay, you can close this ticket.

If you say; we can make changes on our code so that our users do not experience this problem, then keep this ticket open.

#3 @pbearne
3 months ago

  • Owner set to pbearne
  • Status changed from new to assigned

I think this has been fixed

Can we close this?

Note: See TracTickets for help on using tickets.