Just reporting this to be helpful, we're actually going to work around this a different way on the project we're using it on.
With Core 8.7.x and VBO 2.x this module could successfully add roles to users in bulk based upon a view result. After upgrading to 8.9.x the are no new errors, notices etc, but the array of available roles retuned by the listRoles function is empty, so no job can be run. This is when the VBO is run as an admin will all permissions.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | administerusersbyrole.role_action.3172576-6.patch | 989 bytes | adamps |
Comments
Comment #2
thomasmurphy commentedComment #3
adamps commentedYou say that
listRoles()returns empty. You say that you are running as admin with all permissions. Well this is expected, see the comment in preAccess():I don't understand how
listRoles()is called when you hit the bug. It is called formadministerusersbyrole_query_administerusersbyrole_edit_access_alter()so maybe you added the tagadministerusersbyrole_edit_accessto a view???The description for this tag is this:
If you are running as admin, then it has no effect because the admin can modify all users.
Comment #4
morvaim commentedIn the case of administrator
listRoles()is not called fromadministerusersbyrole_query_administerusersbyrole_edit_access_alter(), because in the first condition it says the code should only run if the current user DOES NOT haveadminister userspermission.\Drupal\views_bulk_operations\src\Form\ConfigureActioncalls$action->buildConfigurationForm($form, $form_state)andbuildConfigurationForm()callslistRoles()andlistRoles()gives back an empty list for admin users in case ofpreAccess()returnsFALSEandpreAccess()returnsFALSE, because the user has theadminister userspermission.So I don't know what could be a solution for this problem, but I think, the problem exists. Just try to change bulk form to views bulk operations form on the user listing view and check with an administrator user can add or remove roles on the user listing page.
Comment #5
adamps commentedThanks the problem is now clear.
Comment #6
adamps commentedI think this might fix it. I would be grateful for any review/testing.
Comment #8
adamps commentedComment #9
bsuttis commentedConfirming I ran into the same issue using a views action to add/remove roles as an Administrator (uid 1), patch provided fixes it.
Comment #11
adamps commentedThanks for the confirmation