Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a65fdf0

Browse files
Store millisecond timestamps as float instead of int to prevent int overflow issues on 32 bit based systems. Issue #43860
1 parent 6d688f6 commit a65fdf0

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Symfony/Component/Messenger/Transport/RedisExt/Connection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public function reject(string $id): void
248248
}
249249
}
250250

251-
public function add(string $body, array $headers, int $delayInMs = 0): void
251+
public function add(string $body, array $headers, float $delayInMs = 0): void
252252
{
253253
if ($this->autoSetup) {
254254
$this->setup();
@@ -267,7 +267,7 @@ public function add(string $body, array $headers, int $delayInMs = 0): void
267267
throw new TransportException(json_last_error_msg());
268268
}
269269

270-
$score = $this->getCurrentTimeInMilliseconds() + $delayInMs;
270+
$score = $this->getCurrentTimeInMilliseconds() + (float) $delayInMs;
271271
$added = $this->connection->zadd($this->queue, ['NX'], $score, $message);
272272
} else {
273273
$message = json_encode([
@@ -316,9 +316,9 @@ public function setup(): void
316316
$this->autoSetup = false;
317317
}
318318

319-
private function getCurrentTimeInMilliseconds(): int
319+
private function getCurrentTimeInMilliseconds(): float
320320
{
321-
return (int) (microtime(true) * 1000);
321+
return microtime(true) * (float) 1000;
322322
}
323323

324324
public function cleanup(): void

src/Symfony/Component/Messenger/Transport/RedisExt/RedisSender.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function send(Envelope $envelope): Envelope
4242
$delayStamp = $envelope->last(DelayStamp::class);
4343
$delayInMs = null !== $delayStamp ? $delayStamp->getDelay() : 0;
4444

45-
$this->connection->add($encodedMessage['body'], $encodedMessage['headers'] ?? [], $delayInMs);
45+
$this->connection->add($encodedMessage['body'], $encodedMessage['headers'] ?? [], (float) $delayInMs);
4646

4747
return $envelope;
4848
}

0 commit comments

Comments
 (0)