[wp-trac] [WordPress Trac] #17860: Multisite: Incorrect User Counts on Sites

WordPress Trac noreply at wordpress.org
Tue Nov 13 10:40:19 UTC 2012


#17860: Multisite: Incorrect User Counts on Sites
--------------------------+------------------------------
 Reporter:  cgrymala      |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Multisite     |     Version:  3.1.3
 Severity:  normal        |  Resolution:
 Keywords:                |
--------------------------+------------------------------

Comment (by nacin):

 > To make things more complicated, if they have capabilities and no role;
 WordPress won't even let you assign a role to them.

 That seems like a separate bug.

 Reading through this ticket, I am reminded of two others: the recent
 #22361, and the older and infamous #10201.

 There are a number of deficiencies when it comes to roles and
 capabilities, and there are two ways to address them. They are not
 mutually exclusive. One is to start plotting a complete overhaul (akin to
 #10201). The other is to start chipping away at particular issues. For
 example, make multiple roles a little less painful, and/or fix what I
 quoted above.

 Reading the original report here, it seems like this particular issue is
 that the way we decide to show users in the list table is more restrictive
 than what we use to count them. Obviously, those should be the same. And I
 would say that if they have a meta_key of any value (other than a:0:{}),
 they should be counted, and they should be displayed in some form. And
 obviously, displaying their roles/capabilities, and editing their roles,
 should not be so painful.

 So, we agree there's a problem here. Now, we can start to look at the
 solution. It appears quite obvious that the bug is in the list table, as
 kawauso pointed out.

 This was added for #12711, see [13883] and [13894]. Essentially, it was
 added to avoid showing users with an empty meta key (the fix was to stop
 creating empty meta keys, and remove them instead), but instead it avoids
 users with no role (which ensnares users with a single cap). Two ways out
 of this mess —
  * An upgrade routine to remove empty cap keys, as they should not exist.
 As cap key names are based on the blog_id, this is not fun, as it would
 need to be run on individual sites, despite being a global table. With an
 upgrade, may just remove the check.
  * Changing `empty( $role )` to `empty( $user->caps )`.

 Now, with that change, I guess the user would show as having "None" for a
 role. It's tough to consider a user being a member of the blog without
 having a role, but it *is* possible, and get_blogs_of_user() does consider
 the user to be part of this site, as does is_user_member_of_blog().

 And so I ask you, is the bug really "incorrect user counts", or is it that
 users are improperly hidden? I would think that it is the latter, in which
 case, I've attached a patch that should do the trick.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/17860#comment:10>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list