Problem/Motivation
Drupal users can be assigned multiple roles. The query condition currently in place does not correctly handle the case where multiple roles are assigned to a user. As the module functions currently, the user's roles must exactly match the configuration for excluded roles in block_inactive_users to be ignored by the blocking logic.
Steps to reproduce
- As Admin, create a user with at least two roles
- From administration/config form /admin/config/people/block_inactive_users
- Set "Time period (in months)" to 0 to be able to test immediately
- Check "include users who have never logged in"
- Select only one of the two roles user was set up with
- Click "Disable Inactive Users"
- Confirm user was blocked
Proposed resolution
The root cause of this is the roles joined into the query to determine which users to block have separate rows per role.
Example user__roles table:
bundle | deleted | entity_id | revision_id | langcode | delta | roles_target_id |
+--------+---------+-----------+-------------+----------+-------+-----------------+
| user | 0 | 1 | 1 | en | 0 | administrator |
| user | 0 | 2 | 2 | en | 0 | content_editor |
| user | 0 | 2 | 2 | en | 1 | administrator
When these row are joined into the query the user may have multiple joined rows from the user__roles table;
Conditionally excluding one of the rows does not remove all of the user's rows from the query results. Therefore, a false positive is given when only one of the roles is selected from exclusion.
Option 1: The documentation of the "Exclude users with role(s)" functionality can be updated to specify complete match
Option 2: In order to work as logically expected the query or surrounding logic should be updated to allow one role exclusion to exclude the user.
Remaining tasks
Implement fix to query(ies) or surrounding logic
User interface changes
None
API changes
None
Data model changes
None