The UserFieldRole plugin fails to compare correctly for a Role name that is more than a single word.
Create a role: "First edit"
Create a user with this role
Create a "access rule only" and set the handler to user has role, selecting the role created above. Set it to control access to edit.
Add a selection rule which will cause the rule to be selected
Check a content item that would select the rule against the user created and note that it fails with: The 'Current user: Roles (in First edit)' access rule failed..
The code in UserFieldRole has this comment
// Roles are stored on the access policy with underscores "_" however they
// are stored in Drupal with a space. We need to replace that underscore
// with the space.
But \Drupal\user\RoleForm has this
$form['id'] = [
'#type' => 'machine_name',
'#default_value' => $entity->id(),
'#required' => TRUE,
'#disabled' => !$entity->isNew(),
'#size' => 30,
'#maxlength' => 64,
'#machine_name' => [
'exists' => ['\Drupal\user\Entity\Role', 'load'],
],
];
And \Drupal\Core\Render\Element\MachineName::validateMachineName does not allow spaces.
Remove the parsing of underscores into space.
Active
2.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
No activities found.