8000 feature #39852 [Security] RoleHierarchy returns an unique array of ro… · symfony/symfony@93e853d · GitHub
[go: up one dir, main page]

Skip to content

Commit 93e853d

Browse files
committed
feature #39852 [Security] RoleHierarchy returns an unique array of roles (lyrixx)
This PR was merged into the 5.3-dev branch. Discussion ---------- [Security] RoleHierarchy returns an unique array of roles | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | no | New feature? | yes: performance | Deprecations? | | Tickets | | License | MIT | Doc PR | Speedup: https://github.com/symfony/symfony/blob/5.x/src/Symfony/Component/Security/Core/Authorization/Voter/RoleVoter.php#L48 BTW, why isn't an `in_array()` there? Commits ------- aa0494c [Security] RoleHierarchy returns unique an unique array of roles
2 parents 771a2a4 + aa0494c commit 93e853d

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Symfony/Component/Security/Core/Role/RoleHierarchy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function getReachableRoleNames(array $roles): array
4848
}
4949
}
5050

51-
return $reachableRoles;
51+
return array_values(array_unique($reachableRoles));
5252
}
5353

5454
protected function buildRoleMap()

src/Symfony/Component/Security/Core/Tests/Role/RoleHierarchyTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ public function testGetReachableRoleNames()
2828
$this->assertEquals(['ROLE_ADMIN', 'ROLE_USER'], $role->getReachableRoleNames(['ROLE_ADMIN']));
2929
$this->assertEquals(['ROLE_FOO', 'ROLE_ADMIN', 'ROLE_USER'], $role->getReachableRoleNames(['ROLE_FOO', 'ROLE_ADMIN']));
3030
$this->assertEquals(['ROLE_SUPER_ADMIN', 'ROLE_ADMIN', 'ROLE_FOO', 'ROLE_USER'], $role->getReachableRoleNames(['ROLE_SUPER_ADMIN']));
31+
$this->assertEquals(['ROLE_SUPER_ADMIN', 'ROLE_ADMIN', 'ROLE_FOO', 'ROLE_USER'], $role->getReachableRoleNames(['ROLE_SUPER_ADMIN', 'ROLE_SUPER_ADMIN']));
3132
}
3233
}

0 commit comments

Comments
 (0)
0