summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabien Potencier <fabien.potencier@gmail.com>2016-06-29 17:24:22 +0200
committerFabien Potencier <fabien.potencier@gmail.com>2016-06-29 17:24:22 +0200
commitee959deafc05bb80f579827bfea736082949911b (patch)
treeea3d3fcb6835bbc247455ba9193392cb62a7e413
parentad26beddbb9a24638754523d7232daab3580e4ae (diff)
parent01bedc08b8d6c8023b5f05d3c2442371409fbb51 (diff)
downloadsymfony-security-ee959deafc05bb80f579827bfea736082949911b.zip
symfony-security-ee959deafc05bb80f579827bfea736082949911b.tar.gz
symfony-security-ee959deafc05bb80f579827bfea736082949911b.tar.bz2
bug #18934 Fixed some issues of the AccessDecisionManager profiler (javiereguiluz)v3.1.2
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 https://github.com/schmittjoh/JMSSecurityExtraBundle/issues/207 | License | MIT | Doc PR | - Commits ------- 082f1b5 Fixed some issues of the AccessDecisionManager profiler
-rw-r--r--Core/Authorization/DebugAccessDecisionManager.php20
1 files changed, 13 insertions, 7 deletions
diff --git a/Core/Authorization/DebugAccessDecisionManager.php b/Core/Authorization/DebugAccessDecisionManager.php
index 540d998..1a04bc1 100644
--- a/Core/Authorization/DebugAccessDecisionManager.php
+++ b/Core/Authorization/DebugAccessDecisionManager.php
@@ -26,17 +26,19 @@ class DebugAccessDecisionManager implements AccessDecisionManagerInterface
{
private $manager;
private $strategy;
- private $voters;
+ private $voters = array();
private $decisionLog = array();
- public function __construct(AccessDecisionManager $manager)
+ public function __construct(AccessDecisionManagerInterface $manager)
{
$this->manager = $manager;
- // The strategy is stored in a private property of the decorated service
- $reflection = new \ReflectionProperty($manager, 'strategy');
- $reflection->setAccessible(true);
- $this->strategy = $reflection->getValue($manager);
+ if ($this->manager instanceof AccessDecisionManager) {
+ // The strategy is stored in a private property of the decorated service
+ $reflection = new \ReflectionProperty(AccessDecisionManager::class, 'strategy');
+ $reflection->setAccessible(true);
+ $this->strategy = $reflection->getValue($manager);
+ }
}
/**
@@ -60,6 +62,10 @@ class DebugAccessDecisionManager implements AccessDecisionManagerInterface
*/
public function setVoters(array $voters)
{
+ if (!$this->manager instanceof AccessDecisionManager) {
+ return;
+ }
+
$this->voters = $voters;
$this->manager->setVoters($voters);
}
@@ -72,7 +78,7 @@ class DebugAccessDecisionManager implements AccessDecisionManagerInterface
// The $strategy property is misleading because it stores the name of its
// method (e.g. 'decideAffirmative') instead of the original strategy name
// (e.g. 'affirmative')
- return strtolower(substr($this->strategy, 6));
+ return null === $this->strategy ? '-' : strtolower(substr($this->strategy, 6));
}
/**