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

Skip to content

Commit 37328e3

Browse files
committed
bug #45017 [Security] Fix retrieving strategy for custom AccessDecisionManager (javer)
This PR was merged into the 6.1 branch. Discussion ---------- [Security] Fix retrieving strategy for custom AccessDecisionManager | Q | A | ------------- | --- | Branch? | 6.1 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Adding property types to `TraceableAccessDecisionManager` in 85065e4 leads to the TypeError when using custom `AccessDecisionManager` in the application: ``` Error: Typed property Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager::$strategy must not be accessed before initialization ``` I'm targeting 6.1 branch, because property types are here only in 6.1 branch. Previously they were in 6.0 also, but later it was reverted. Commits ------- 50dd188 Fix retrieving strategy for custom AccessDecisionManager
2 parents 22fd05a + 50dd188 commit 37328e3

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Symfony/Component/Security/Core/Authorization/TraceableAccessDecisionManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
class TraceableAccessDecisionManager implements AccessDecisionManagerInterface
2727
{
2828
private AccessDecisionManagerInterface $manager;
29-
private AccessDecisionStrategyInterface $strategy;
29+
private ?AccessDecisionStrategyInterface $strategy = null;
3030
/** @var iterable<mixed, VoterInterface> */
3131
private iterable $voters = [];
3232
private array $decisionLog = []; // All decision logs

src/Symfony/Component/Security/Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,4 +274,13 @@ public function testAccessDecisionManagerCalledByVoter()
274274
],
275275
], $sut->getDecisionLog());
276276
}
277+
278+
public function testCustomAccessDecisionManagerReturnsEmptyStrategy()
279+
{
280+
$admMock = $this->createMock(AccessDecisionManagerInterface::class);
281+
282+
$adm = new TraceableAccessDecisionManager($admMock);
283+
284+
$this->assertEquals('-', $adm->getStrategy());
285+
}
277286
}

0 commit comments

Comments
 (0)