Opened 11 years ago
Closed 11 years ago
#34495 closed defect (bug) (fixed)
Negative number for "No role"?
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.4 | Priority: | normal |
| Severity: | normal | Version: | 4.4 |
| Component: | Users | Keywords: | needs-patch |
| Focuses: | Cc: |
Description
Is it possible? See attached screenshot.
Attachments (1)
Change History (13)
#2
@
11 years ago
Sorry, I had to go and did not have time to find additional details. There are 11 users, one of them (admin) has 2 roles (Administrator and Keymaster), all others only one (standard WP roles). Keymaster role is probably from bbPress, but this plugin is not active now. There is no user without role. Any ideas what should I check tomorrow?
#3
@
11 years ago
I just tried various combinations of activating and deactivating bbPress to try and recreate a user without a role and could not.
#4
@
11 years ago
So, I tried to debug it a little bit and problem is here: https://core.trac.wordpress.org/browser/trunk/src/wp-includes/user-functions.php#L779
$role_counts['none'] = ( $total_users - array_sum( $role_counts ) );
This logic does not work for me.
$role_counts:
array(5) { ["administrator"]=> int(1) ["editor"]=> int(1) ["author"]=> int(2) ["subscriber"]=> int(7) ["bbp_keymaster"]=> int(1) }
array_sum( $role_counts ): int(12)
$total_users: int(11)
Result is -1
bbPress plugin is deactivated, but was active before and Administrator is also Keymaster.
#5
@
11 years ago
- Keywords needs-testing added; reporter-feedback removed
- Milestone changed from Awaiting Review to 4.4
- Owner set to johnbillion
- Status changed from new to reviewing
#6
@
11 years ago
- Keywords needs-patch added; needs-testing removed
This is reproducible if you've a user on your site with a role that no longer exists (for example by using the Members plugin to add a role, assigning a user that role, then deactivating the Members plugin) and then subsequently activate a plugin such as bbPress which also adds a custom user role. I've not dug into the root cause yet.
Can you provide some more info please? A question does not make a good bug report.
It looks like you may have some malformed users in your users table.