diff --git a/core/modules/user/lib/Drupal/user/Access/RoleAccessCheck.php b/core/modules/user/lib/Drupal/user/Access/RoleAccessCheck.php index 104763d..cb44b96 100644 --- a/core/modules/user/lib/Drupal/user/Access/RoleAccessCheck.php +++ b/core/modules/user/lib/Drupal/user/Access/RoleAccessCheck.php @@ -40,14 +40,14 @@ public function access(Route $route, Request $request) { $explode_and = array_filter(array_map('trim', explode('+', $rid_string))); if (count($explode_and) > 1) { - $diff = array_diff($explode_and, array_keys($account->roles)); + $diff = array_diff($explode_and, $account->roles); if (empty($diff)) { return TRUE; } } else { $explode_or = array_filter(array_map('trim', explode(',', $rid_string))); - $intersection = array_intersect($explode_or, array_keys($account->roles)); + $intersection = array_intersect($explode_or, $account->roles); if (!empty($intersection)) { return TRUE; } diff --git a/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php b/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php index b13c515..c0d383c 100644 --- a/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php +++ b/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php @@ -112,17 +112,26 @@ public function roleAccessProvider() { // Setup one user with the first role, one with the second, one with both // and one final without any of these two roles. - $account_1 = new User(array('uid' => 1), 'user'); - $account_1->roles[] = $rid_1; - $account_2 = new User(array('uid' => 2), 'user'); - $account_2->roles[] = $rid_2; + $account_1 = (object) array( + 'uid' => 1, + 'roles' => array($rid_1), + ); - $account_12 = new User(array('uid' => 3), 'user'); - $account_12->roles[] = $rid_1; - $account_12->roles[] = $rid_2; + $account_2 = (object) array( + 'uid' => 2, + 'roles' => array($rid_2), + ); - $account_none = new User(array('uid' => 4), 'user'); + $account_12 = (object) array( + 'uid' => 3, + 'roles' => array($rid_1, $rid_2), + ); + + $account_none = (object) array( + 'uid' => 1, + 'roles' => array(), + ); // Setup expected values; specify which paths can be accessed by which user. return array( @@ -168,7 +177,7 @@ public function testRoleAccess($path, $grant_accounts, $deny_accounts) { $GLOBALS['user'] = $account; $subrequest = Request::create($path, 'GET'); - $message = sprintf('Access denied for user %s with the roles %s on path: %s', $account->id(), implode(', ', $account->roles), $path); + $message = sprintf('Access denied for user %s with the roles %s on path: %s', $account->uid, implode(', ', $account->roles), $path); $has_access = $role_access_check->access($collection->get($path), $subrequest); $this->assertEmpty($has_access , $message); }