Skip to content

Commit 2308e99

Browse files
committed
bug #50287 [Messenger] Store dates in UTC when using Doctrine (nicolas-grekas)
This PR was merged into the 6.3 branch. Discussion ---------- [Messenger] Store dates in UTC when using Doctrine | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Spotted by running the receiver in an UTC container and the sender in a non-UTC process. Commits ------- 5675379 [Messenger] Store dates in UTC when using Doctrine
2 parents 3c97d93 + 5675379 commit 2308e99

File tree

1 file changed

+3
-3
lines changed
  • src/Symfony/Component/Messenger/Bridge/Doctrine/Transport

1 file changed

+3
-3
lines changed

src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public static function buildConfiguration(#[\SensitiveParameter] string $dsn, ar
125125
*/
126126
public function send(string $body, array $headers, int $delay = 0): string
127127
{
128-
$now = new \DateTimeImmutable();
128+
$now = new \DateTimeImmutable('UTC');
129129
$availableAt = $now->modify(sprintf('+%d seconds', $delay / 1000));
130130

131131
$queryBuilder = $this->driverConnection->createQueryBuilder()
@@ -221,7 +221,7 @@ public function get(): ?array
221221
->update($this->configuration['table_name'])
222222
->set('delivered_at', '?')
223223
->where('id = ?');
224-
$now = new \DateTimeImmutable();
224+
$now = new \DateTimeImmutable('UTC');
225225
$this->executeStatement($queryBuilder->getSQL(), [
226226
$now,
227227
$doctrineEnvelope['id'],
@@ -342,7 +342,7 @@ public function getExtraSetupSqlForTable(Table $createdTable): array
342342

343343
private function createAvailableMessagesQueryBuilder(): QueryBuilder
344344
{
345-
$now = new \DateTimeImmutable();
345+
$now = new \DateTimeImmutable('UTC');
346346
$redeliverLimit = $now->modify(sprintf('-%d seconds', $this->configuration['redeliver_timeout']));
347347

348348
return $this->createQueryBuilder()

0 commit comments

Comments
 (0)