Opened 8 years ago
Closed 19 months ago
#43393 closed defect (bug) (invalid)
get_user_by can return wrong user info
| Reported by: | hberberoglu | Owned by: | pbearne |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Users | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: | performance |
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 (4)
#2
@
8 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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.