[wp-trac] [WordPress Trac] #29785: User count not correct
WordPress Trac
noreply at wordpress.org
Mon Sep 29 10:52:30 UTC 2014
#29785: User count not correct
--------------------------+-----------------------------
Reporter: psoluch | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Users | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
'''Are you using either the latest version of WordPress, or the latest
development version?
'''
SVN trunk version
'''What's the problem?'''
Count of users is not correct on the Users list in WP Admin.
[[Image()]]
'''Reason?'''
The count_users() function in wp-includes/user.php uses the user_meta
table to count the number of users with specific role. If (for some
reason) the entry in users table get deleted and the corresponding
user_meta entries don't - the count will not be correct.
'''How did it happen?'''
Not sure... The user had to be deleted manually from the DB or a custom
function did that. It's a rather rare case but might happen.
'''What steps should be taken to consistently reproduce the problem?
'''
1. Delete manually a user from a users table (leave the users_meta
entries)
2. Go to admin and check the number of users in the group of the
previously deleted user
'''How it can be fixed'''
A joint query on the users and user_meta tables. This not only fixes the
problem, but is the more consistent way of doing things - the query used
for the list of users uses a joint query too.
'''Performance implications'''
There might be some performance implications - the joint query will be
slower, but not by much - it's done on a index column (user_id). It
shouldn't have an impact, but someone with more knowledge on the matter
should comment.
'''Patch'''
[]
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29785>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list