Active
Project:
Administer Users by Role
Version:
8.x-3.6
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
2 Jul 2026 at 12:27 UTC
Updated:
2 Jul 2026 at 12:31 UTC
Jump to comment: Most recent
Error:
TypeError: array_keys(): Argument #1 ($array) must be of type array, null given in array_keys() (line 224 of modules/contrib/administerusersbyrole/administerusersbyrole.module).
Issue:
function administerusersbyrole_form_user_form_submit(array $form, FormStateInterface $form_state) {
// Preserve the setting for any roles that were not visible in the form.
$preserve = array_diff($form['account']['roles']['#default_value'], array_keys($form["account"]["roles"]["#options"]));
$roles = array_merge($form_state->getValue('roles'), $preserve);
$form_state->setValue('roles', $roles);
}
- Log in as a user who does not have permission to see/assign any roles on the user edit form (e.g. no assignable roles are available to them, or the roles element is otherwise not built with #options).
- Edit a user account and submit the form.
- Observe the fatal error.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments