Skip to content

Commit 371b3a4

Browse files
Merge branch '6.4' into 7.0
* 6.4: Update FileProfilerStorage.php [Security] Allow custom scheme to be used as redirection URIs [Validator] Do not mock metadata factory on debug command tests [HttpKernel][WebProfilerBundle] Fix search feature [ErrorHandler] Avoid compile crash while trying to find candidate when a class is not found [Security] Make `PersistentToken` immutable and tell `TokenProviderInterface::updateToken()` implementations should accept `DateTimeInterface` do not listen to signals if the pcntl extension is missing [DependencyInjection] Improve reporting named autowiring aliases [DependencyInjection] Make better use of memory and CPU during auto-discovery update Intl component to take into account B-variant when converting Alpha3 to Alpha2. fixing issue with Darwin. [VarDumper] Fix dumping `ArrayObject` with `DumpDataCollector` [VarDumper] Add tests to demonstrate a bug when dumping ArrayObject with full stack fmk [DebugBundle][FrameworkBundle] Fix using the framework without the Console component [FrameworkBundle] Add missing monolog channel tag to the `messenger:failed:retry` command fetch all known ChoiceType values at once [RateLimiter] fix incorrect retryAfter of FixedWindow Fix Finder phpdoc [TwigBundle] Allow omitting the `autoescape_service_method` option when `autoescape_service` is set to an invokable service id [PropertyAccess] Auto-cast from/to DateTime/Immutable when appropriate
2 parents 39b0ae2 + e15dc47 commit 371b3a4

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Security/RememberMe/DoctrineTokenProvider.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* `username` varchar(200) NOT NULL
4040
* );
4141
*/
42-
class DoctrineTokenProvider implements TokenProviderInterface, TokenVerifierInterface
42+
final class DoctrineTokenProvider implements TokenProviderInterface, TokenVerifierInterface
4343
{
4444
public function __construct(
4545
private Connection $conn,
@@ -55,7 +55,7 @@ public function loadTokenBySeries(string $series): PersistentTokenInterface
5555
$stmt = $this->conn->executeQuery($sql, $paramValues, $paramTypes);
5656
$row = $stmt->fetchAssociative() ?: throw new TokenNotFoundException('No token found.');
5757

58-
return new PersistentToken($row['class'], $row['username'], $series, $row['value'], new \DateTime($row['last_used']));
58+
return new PersistentToken($row['class'], $row['username'], $series, $row['value'], new \DateTimeImmutable($row['last_used']));
5959
}
6060

6161
public function deleteTokenBySeries(string $series): void
@@ -66,7 +66,7 @@ public function deleteTokenBySeries(string $series): void
6666
$this->conn->executeStatement($sql, $paramValues, $paramTypes);
6767
}
6868

69-
public function updateToken(string $series, #[\SensitiveParameter] string $tokenValue, \DateTime $lastUsed): void
69+
public function updateToken(string $series, #[\SensitiveParameter] string $tokenValue, \DateTimeInterface $lastUsed): void
7070
{
7171
$sql = 'UPDATE rememberme_token SET value=:value, lastUsed=:lastUsed WHERE series=:series';
7272
$paramValues = [

Tests/Security/RememberMe/DoctrineTokenProviderTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function testCreateNewToken()
2929
{
3030
$provider = $this->bootstrapProvider();
3131

32-
$token = new PersistentToken('someClass', 'someUser', 'someSeries', 'tokenValue', new \DateTime('2013-01-26T18:23:51'));
32+
$token = new PersistentToken('someClass', 'someUser', 'someSeries', 'tokenValue', new \DateTimeImmutable('2013-01-26T18:23:51'));
3333
$provider->createNewToken($token);
3434

3535
$this->assertEquals($provider->loadTokenBySeries('someSeries'), $token);
@@ -47,7 +47,7 @@ public function testUpdateToken()
4747
{
4848
$provider = $this->bootstrapProvider();
4949

50-
$token = new PersistentToken('someClass', 'someUser', 'someSeries', 'tokenValue', new \DateTime('2013-01-26T18:23:51'));
50+
$token = new PersistentToken('someClass', 'someUser', 'someSeries', 'tokenValue', new \DateTimeImmutable('2013-01-26T18:23:51'));
5151
$provider->createNewToken($token);
5252
$provider->updateToken('someSeries', 'newValue', $lastUsed = new \DateTime('2014-06-26T22:03:46'));
5353
$token = $provider->loadTokenBySeries('someSeries');
@@ -59,7 +59,7 @@ public function testUpdateToken()
5959
public function testDeleteToken()
6060
{
6161
$provider = $this->bootstrapProvider();
62-
$token = new PersistentToken('someClass', 'someUser', 'someSeries', 'tokenValue', new \DateTime('2013-01-26T18:23:51'));
62+
$token = new PersistentToken('someClass', 'someUser', 'someSeries', 'tokenValue', new \DateTimeImmutable('2013-01-26T18:23:51'));
6363
$provider->createNewToken($token);
6464
$provider->deleteTokenBySeries('someSeries');
6565

@@ -76,7 +76,7 @@ public function testVerifyOutdatedTokenAfterParallelRequest()
7676
$newValue = 'newValue';
7777

7878
// setup existing token
79-
$token = new PersistentToken('someClass', 'someUser', $series, $oldValue, new \DateTime('2013-01-26T18:23:51'));
79+
$token = new PersistentToken('someClass', 'someUser', $series, $oldValue, new \DateTimeImmutable('2013-01-26T18:23:51'));
8080
$provider->createNewToken($token);
8181

8282
// new request comes in requiring remember-me auth, which updates the token
@@ -101,7 +101,7 @@ public function testVerifyOutdatedTokenAfterParallelRequestFailsAfter60Seconds()
101101
$newValue = 'newValue';
102102

103103
// setup existing token
104-
$token = new PersistentToken('someClass', 'someUser', $series, $oldValue, new \DateTime('2013-01-26T18:23:51'));
104+
$token = new PersistentToken('someClass', 'someUser', $series, $oldValue, new \DateTimeImmutable('2013-01-26T18:23:51'));
105105
$provider->createNewToken($token);
106106

107107
// new request comes in requiring remember-me auth, which updates the token

0 commit comments

Comments
 (0)