8000 feature #37480 [Messenger] add redeliveredAt in RedeliveryStamp const… · symfony/symfony@681c666 · GitHub
[go: up one dir, main page]

Skip to content

Commit 681c666

Browse files
committed
feature #37480 [Messenger] add redeliveredAt in RedeliveryStamp construct (qkdreyer)
This PR was squashed before being merged into the 5.2-dev branch. Discussion ---------- [Messenger] add redeliveredAt in RedeliveryStamp construct | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - --- this would allows one to correctly unserialize a RedeliveryStamp with a custom serializer not using the php serialize function Commits ------- 64d2683 [Messenger] add redeliveredAt in RedeliveryStamp construct
2 parents 4105e93 + 64d2683 commit 681c666

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/Symfony/Component/Messenger/Stamp/RedeliveryStamp.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ final class RedeliveryStamp implements StampInterface
2424
private $exceptionMessage;
2525
private $flattenException;
2626

27-
public function __construct(int $retryCount, string $exceptionMessage = null, FlattenException $flattenException = null)
27+
public function __construct(int $retryCount, string $exceptionMessage = null, FlattenException $flattenException = null, \DateTimeImmutable $redeliveredAt = null)
2828
{
2929
$this->retryCount = $retryCount;
3030
$this->exceptionMessage = $exceptionMessage;
3131
$this->flattenException = $flattenException;
32-
$this->redeliveredAt = new \DateTimeImmutable();
32+
$this->redeliveredAt = $redeliveredAt ?? new \DateTimeImmutable();
3333
}
3434

3535
public static function getRetryCountFromEnvelope(Envelope $envelope): int

src/Symfony/Component/Messenger/Tests/Stamp/RedeliveryStampTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,10 @@ public function testGettersPopulated()
3333
$this->assertSame('exception message', $stamp->getExceptionMessage());
3434
$this->assertSame($flattenException, $stamp->getFlattenException());
3535
}
36+
37+
public function testSerialization()
38+
{
39+
$stamp = new RedeliveryStamp(10, null, null, \DateTimeImmutable::createFromFormat(\DateTimeInterface::ISO8601, '2005-08-15T15:52:01+0000'));
40+
$this->assertSame('2005-08-15T15:52:01+0000', $stamp->getRedeliveredAt()->format(\DateTimeInterface::ISO8601));
41+
}
3642
}

0 commit comments

Comments
 (0)
0