Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
On user creating I get:
Notice: Undefined variable: assigned_roles in roleassign_form_alter() (line 109 of modules/contrib/roleassign/roleassign.module).
Warning: array_keys() expects parameter 1 to be array, null given in roleassign_form_alter() (line 109 of modules/contrib/roleassign/roleassign.module).
Warning: Invalid argument supplied for foreach() in Drupal\Core\Render\Element\Checkboxes::valueCallback() (line 105 of core/lib/Drupal/Core/Render/Element/Checkboxes.php).
Looking on the code i see that he is trying to set default based on assigned_roles:
$roles_field = array(
'#type' => 'checkboxes',
'#title' => t('Assignable roles'),
'#options' => $assignable_roles,
'#default_value' => array_keys($assigned_roles),
'#description' => t('The user receives the combined permissions of all roles selected here and the following roles: %roles.', array('%roles' => implode('$
);
Are these asigned roles the user assigned roles? The user im using cannot create an user of the same role.
Comment | File | Size | Author |
---|---|---|---|
#4 | 2657668-4.patch | 763 bytes | salvis |
|
Comments
Comment #2
svendecabooterNormally this array should at least contain "authenticated user", but presumably there might be cases where that's not true.
Attached is a patch that adds extra checks to avoid these PHP warnings.
Comment #3
salvis"authenticated user" should be in $sticky_roles, not in $assigned_roles.
Thanks for the report and the patch!
Comment #4
salvisActually, when going to admin/people/create, $assigned_roles is not even assigned — empty() is the test to use.
Comment #5
salvisQueued for 8 hours? Never mind...
Comment #7
salvisThanks!