Skip to content

Commit 232f25f

Browse files
committed
Merge branch '5.4' into 6.4
* 5.4: [Filesystem] Fix str_contains deprecation [Security] Correctly initialize the voter property [FrameworkBundle] Fix typo Update `changed-translation-files` step with native git diff command [Lock] Check the correct SQLSTATE error code for MySQL [ErrorHandler] Fix `ErrorHandlerTest::tearDown()` visibility [Lock] compatiblity with redis cluster 7 fix: typo
2 parents b7825ec + 411190c commit 232f25f

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

DataCollector/SecurityDataCollector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ public function collect(Request $request, Response $response, ?\Throwable $excep
131131
// collect voters and access decision manager information
132132
if ($this->accessDecisionManager instanceof TraceableAccessDecisionManager) {
133133
$this->data['voter_strategy'] = $this->accessDecisionManager->getStrategy();
134+
$this->data['voters'] = [];
134135

135136
foreach ($this->accessDecisionManager->getVoters() as $voter) {
136137
if ($voter instanceof TraceableVoter) {

Tests/DataCollector/SecurityDataCollectorTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,36 @@ public function dispatch(object $event, ?string $eventName = null): object
397397
$this->assertSame($dataCollector->getVoterStrategy(), $strategy, 'Wrong value returned by getVoterStrategy');
398398
}
399399

400+
public function testGetVotersIfAccessDecisionManagerHasNoVoters()
401+
{
402+
$strategy = MainConfiguration::STRATEGY_AFFIRMATIVE;
403+
404+
$accessDecisionManager = $this->createMock(TraceableAccessDecisionManager::class);
405+
406+
$accessDecisionManager
407+
->method('getStrategy')
408+
->willReturn($strategy);
409+
410+
$accessDecisionManager
411+
->method('getVoters')
412+
->willReturn([]);
413+
414+
$accessDecisionManager
415+
->method('getDecisionLog')
416+
->willReturn([[
417+
'attributes' => ['view'],
418+
'object' => new \stdClass(),
419+
'result' => true,
420+
'voterDetails' => [],
421+
]]);
422+
423+
$dataCollector = new SecurityDataCollector(null, null, null, $accessDecisionManager, null, null, true);
424+
425+
$dataCollector->collect(new Request(), new Response());
426+
427+
$this->assertEmpty($dataCollector->getVoters());
428+
}
429+
400430
public static function provideRoles(): array
401431
{
402432
return [

0 commit comments

Comments
 (0)