Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1b86fc0

Browse files
HaehnchenDaniel Espendiller
authored and
Daniel Espendiller
committed
AbstractVoter should abstain string objects
1 parent 0bd8b58 commit 1b86fc0

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Symfony/Component/Security/Core/Authorization/Voter/AbstractVoter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function supportsClass($class)
5858
*/
5959
public function vote(TokenInterface $token, $object, array $attributes)
6060
{
61-
if (!$object || !$this->supportsClass(get_class($object))) {
61+
if (!$object || !is_object($object) || !$this->supportsClass(get_class($object))) {
6262
return self::ACCESS_ABSTAIN;
6363
}
6464

src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AbstractVoterTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function getTests()
3939
array(array('EDIT'), VoterInterface::ACCESS_ABSTAIN, $this, 'ACCESS_ABSTAIN if class is not supported'),
4040

4141
array(array('EDIT'), VoterInterface::ACCESS_ABSTAIN, null, 'ACCESS_ABSTAIN if object is null'),
42+
array(array('EDIT'), VoterInterface::ACCESS_ABSTAIN, 'foo', 'ACCESS_ABSTAIN if object is string'),
4243

4344
array(array(), VoterInterface::ACCESS_ABSTAIN, new \stdClass(), 'ACCESS_ABSTAIN if no attributes were provided'),
4445
);

0 commit comments

Comments
 (0)