diff --git a/core/modules/user/src/Plugin/Condition/UserRole.php b/core/modules/user/src/Plugin/Condition/UserRole.php index 2a67813..8724489 100644 --- a/core/modules/user/src/Plugin/Condition/UserRole.php +++ b/core/modules/user/src/Plugin/Condition/UserRole.php @@ -61,12 +61,13 @@ public function submitConfigurationForm(array &$form, array &$form_state) { * {@inheritdoc} */ public function summary() { - if (count($this->configuration['roles']) > 1) { - $roles = $this->configuration['roles']; + // Use the role labels. They will be sanitized below. + $roles = array_intersect_key(user_role_names(), $this->configuration['roles']); + if (count($roles) > 1) { $roles = implode(', ', $roles); } else { - $roles = reset($this->configuration['roles']); + $roles = reset($roles); } if (!empty($this->configuration['negate'])) { return $this->t('The user is not a member of @roles', array('@roles' => $roles)); @@ -81,7 +82,7 @@ public function summary() { */ public function evaluate() { $user = $this->getContextValue('user'); - return (bool) array_intersect(array_filter($this->configuration['roles']), $user->getRoles()); + return (bool) array_intersect($this->configuration['roles'], $user->getRoles()); } } diff --git a/core/modules/user/src/Tests/Condition/UserRoleConditionTest.php b/core/modules/user/src/Tests/Condition/UserRoleConditionTest.php index 1d0e24c..ca02b6d 100644 --- a/core/modules/user/src/Tests/Condition/UserRoleConditionTest.php +++ b/core/modules/user/src/Tests/Condition/UserRoleConditionTest.php @@ -56,8 +56,8 @@ class UserRoleConditionTest extends KernelTestBase { */ public static function getInfo() { return array( - 'name' => 'User Role Condition Plugin', - 'description' => 'Tests that the User Role Condition, provided by the user module, is working properly.', + 'name' => 'User role condition plugin', + 'description' => 'Tests the user role condition', 'group' => 'Condition API', ); }