From 0e1c0d30bc0e079bd60c1167b0aedf9628525942 Mon Sep 17 00:00:00 2001 From: Sven Henneboele Date: Mon, 22 Apr 2013 12:32:24 +0300 Subject: [PATCH 1/2] Role security identity fix Casting the role property in the constructor is necessary to let the equals function binary comparison work properly while using a custom role entity. The security identity retrieval strategy getSecurityIdentities function instantiates the role security identity class passing an object. The constructor will assign this object to $this->role in case it's not an instance of Role. Binary safe comparison will fail even though gettype returns "string". The custom role entity requires a __toString magic method in this case. --- .../Component/Security/Acl/Domain/RoleSecurityIdentity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Acl/Domain/RoleSecurityIdentity.php b/src/Symfony/Component/Security/Acl/Domain/RoleSecurityIdentity.php index 0d3d0d2ca2b14..c60c18ca56c73 100644 --- a/src/Symfony/Component/Security/Acl/Domain/RoleSecurityIdentity.php +++ b/src/Symfony/Component/Security/Acl/Domain/RoleSecurityIdentity.php @@ -34,7 +34,7 @@ public function __construct($role) $role = $role->getRole(); } - $this->role = $role; + $this->role = (string) $role; } /** From 427b54b717a9f04c0e9bbeb69ef509ebd182c062 Mon Sep 17 00:00:00 2001 From: Sven Henneboele Date: Wed, 19 Jun 2013 14:22:56 +0200 Subject: [PATCH 2/2] Role security identity fix The role security identity was only working when using the origin Role class. The construct method is changed to enable support for custom role entities. --- .../Component/Security/Acl/Domain/RoleSecurityIdentity.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Security/Acl/Domain/RoleSecurityIdentity.php b/src/Symfony/Component/Security/Acl/Domain/RoleSecurityIdentity.php index c60c18ca56c73..2c7db29cbae48 100644 --- a/src/Symfony/Component/Security/Acl/Domain/RoleSecurityIdentity.php +++ b/src/Symfony/Component/Security/Acl/Domain/RoleSecurityIdentity.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Security\Acl\Domain; use Symfony\Component\Security\Acl\Model\SecurityIdentityInterface; -use Symfony\Component\Security\Core\Role\Role; +use Symfony\Component\Security\Core\Role\RoleInterface; /** * A SecurityIdentity implementation for roles @@ -30,11 +30,11 @@ final class RoleSecurityIdentity implements SecurityIdentityInterface */ public function __construct($role) { - if ($role instanceof Role) { + if ($role instanceof RoleInterface) { $role = $role->getRole(); } - $this->role = (string) $role; + $this->role = $role; } /**