Skip to content

Commit

Permalink
bug #18934 Fixed some issues of the AccessDecisionManager profiler (j…
Browse files Browse the repository at this point in the history
…aviereguiluz)

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
  • Loading branch information
fabpot committed Jun 29, 2016
2 parents fe6841c + 082f1b5 commit 0b3b0d5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
Expand Up @@ -10,7 +10,7 @@
<argument type="service" id="security.token_storage" on-invalid="ignore" />
<argument type="service" id="security.role_hierarchy" />
<argument type="service" id="security.logout_url_generator" />
<argument type="service" id="debug.security.access.decision_manager" />
<argument type="service" id="security.access.decision_manager" />
</service>
</services>
</container>
@@ -1,8 +1,8 @@
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="debug.security.access.decision_manager" class="Symfony\Component\Security\Core\Authorization\DebugAccessDecisionManager" decorates="security.access.decision_manager" public="false">
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/SecurityBundle/composer.json
Expand Up @@ -17,7 +17,7 @@
],
"require": {
"php": ">=5.5.9",
"symfony/security": "~3.1",
"symfony/security": "~3.1,>=3.1.2",
"symfony/http-kernel": "~2.8|~3.0",
"symfony/polyfill-php70": "~1.0"
},
Expand Down
Expand Up @@ -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);
}
}

/**
Expand All @@ -60,6 +62,10 @@ public function decide(TokenInterface $token, array $attributes, $object = null)
*/
public function setVoters(array $voters)
{
if (!$this->manager instanceof AccessDecisionManager) {
return;
}

$this->voters = $voters;
$this->manager->setVoters($voters);
}
Expand All @@ -72,7 +78,7 @@ public function getStrategy()
// 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));
}

/**
Expand Down

0 comments on commit 0b3b0d5

Please sign in to comment.