Skip to content

Commit 011d4d3

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: (30 commits) [HttpKernel] Add support for configuring log level, and status code by exception class Add return types to HttpCache createSurrogate and createStore methods [Serializer] Fix denormalizing of array with empty body Fix framework configuration when messenger uses without console [Security] Remove annoying deprecation in `UsageTrackingTokenStorage` [Mailer] Improve error message when STARTTLS fails [Security] Add alias for FirewallMapInterface to @security.firewall.map Bump Symfony version to 5.3.10 Update VERSION for 5.3.9 Fix CHANGELOG Update CHANGELOG for 5.3.9 Bump Symfony version to 4.4.33 Update VERSION for 4.4.32 Fix CHANGELOG Update CHANGELOG for 4.4.32 [Workflow] Remove dead code in XML schemas [Runtime] Fix test for env var names Bump Symfony version to 5.3.9 Update VERSION for 5.3.8 Update CHANGELOG for 5.3.8 ...
2 parents e294950 + 0e0c5e8 commit 011d4d3

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Authentication/Token/Storage/UsageTrackingTokenStorage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@ private function getSession(): SessionInterface
8484

8585
private function shouldTrackUsage(): bool
8686
{
87-
return $this->enableUsageTracking;
87+
return $this->enableUsageTracking && $this->container->get('request_stack')->getMainRequest();
8888
}
8989
}

Tests/Authentication/Token/Storage/UsageTrackingTokenStorageTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,18 @@ public function testGetSetToken()
6565
$this->assertSame($token, $trackingStorage->getToken());
6666
$this->assertSame(1, $sessionAccess);
6767
}
68+
69+
public function testWithoutMainRequest()
70+
{
71+
$locator = new class(['request_stack' => function () {
72+
return new RequestStack();
73+
}]) implements ContainerInterface {
74+
use ServiceLocatorTrait;
75+
};
76+
$tokenStorage = new TokenStorage();
77+
$trackingStorage = new UsageTrackingTokenStorage($tokenStorage, $locator);
78+
$trackingStorage->enableUsageTracking();
79+
80+
$this->assertNull($trackingStorage->getToken());
81+
}
6882
}

0 commit comments

Comments
 (0)