Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

Commit ee959de

Browse files
committed
bug #18934 Fixed some issues of the AccessDecisionManager profiler (javiereguiluz)
This PR was squashed before being merged into the 3.1 branch (closes #18934). Discussion ---------- Fixed some issues of the AccessDecisionManager profiler | Q | A | ------------- | --- | Branch? | 3.1 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #19022 https://github.com/symfony/symfony-standard/issues/968 schmittjoh/JMSSecurityExtraBundle#207 | License | MIT | Doc PR | - Commits ------- 082f1b5 Fixed some issues of the AccessDecisionManager profiler
2 parents ad26bed + 01bedc0 commit ee959de

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

Core/Authorization/DebugAccessDecisionManager.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,19 @@ class DebugAccessDecisionManager implements AccessDecisionManagerInterface
2626
{
2727
private $manager;
2828
private $strategy;
29-
private $voters;
29+
private $voters = array();
3030
private $decisionLog = array();
3131

32-
public function __construct(AccessDecisionManager $manager)
32+
public function __construct(AccessDecisionManagerInterface $manager)
3333
{
3434
$this->manager = $manager;
3535

36-
// The strategy is stored in a private property of the decorated service
37-
$reflection = new \ReflectionProperty($manager, 'strategy');
38-
$reflection->setAccessible(true);
39-
$this->strategy = $reflection->getValue($manager);
36+
if ($this->manager instanceof AccessDecisionManager) {
37+
// The strategy is stored in a private property of the decorated service
38+
$reflection = new \ReflectionProperty(AccessDecisionManager::class, 'strategy');
39+
$reflection->setAccessible(true);
40+
$this->strategy = $reflection->getValue($manager);
41+
}
4042
}
4143

4244
/**
@@ -60,6 +62,10 @@ public function decide(TokenInterface $token, array $attributes, $object = null)
6062
*/
6163
public function setVoters(array $voters)
6264
{
65+
if (!$this->manager instanceof AccessDecisionManager) {
66+
return;
67+
}
68+
6369
$this->voters = $voters;
6470
$this->manager->setVoters($voters);
6571
}
@@ -72,7 +78,7 @@ public function getStrategy()
7278
// The $strategy property is misleading because it stores the name of its
7379
// method (e.g. 'decideAffirmative') instead of the original strategy name
7480
// (e.g. 'affirmative')
75-
return strtolower(substr($this->strategy, 6));
81+
return null === $this->strategy ? '-' : strtolower(substr($this->strategy, 6));
7682
}
7783

7884
/**

0 commit comments

Comments
 (0)