Skip to content

Commit 67494ba

Browse files
committed
Cast microtime result to int
1 parent f8024ae commit 67494ba

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/Queue.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public function get(array $query, $runningResetDuration, $waitDurationInMillis =
157157

158158
//reset stuck messages
159159
$this->collection->updateMany(
160-
['running' => true, 'resetTimestamp' => ['$lte' => new \MongoDB\BSON\UTCDateTime(microtime(true) * 1000)]],
160+
['running' => true, 'resetTimestamp' => ['$lte' => new \MongoDB\BSON\UTCDateTime((int)(microtime(true) * 1000))]],
161161
['$set' => ['running' => false]]
162162
);
163163

@@ -170,7 +170,7 @@ public function get(array $query, $runningResetDuration, $waitDurationInMillis =
170170
$completeQuery["payload.{$key}"] = $value;
171171
}
172172

173-
$completeQuery['earliestGet'] = ['$lte' => new \MongoDB\BSON\UTCDateTime(microtime(true) * 1000)];
173+
$completeQuery['earliestGet'] = ['$lte' => new \MongoDB\BSON\UTCDateTime((int)(microtime(true) * 1000))];
174174

175175
$resetTimestamp = time() + $runningResetDuration;
176176
//ints overflow to floats
@@ -329,7 +329,7 @@ public function ackSend(array $message, array $payload, $earliestGet = 0, $prior
329329
'priority' => $priority,
330330
];
331331
if ($newTimestamp) {
332-
$toSet['created'] = new \MongoDB\BSON\UTCDateTime(microtime(true) * 1000);
332+
$toSet['created'] = new \MongoDB\BSON\UTCDateTime((int)(microtime(true) * 1000));
333333
}
334334

335335
//using upsert because if no documents found then the doc was removed (SHOULD ONLY HAPPEN BY SOMEONE MANUALLY)
@@ -396,7 +396,7 @@ public function send(array $payload, $earliestGet = 0, $priority = 0.0)
396396
'resetTimestamp' => new \MongoDB\BSON\UTCDateTime(self::MONGO_INT32_MAX * 1000),
397397
'earliestGet' => new \MongoDB\BSON\UTCDateTime($earliestGet * 1000),
398398
'priority' => $priority,
399-
'created' => new \MongoDB\BSON\UTCDateTime(microtime(true) * 1000),
399+
'created' => new \MongoDB\BSON\UTCDateTime((int)(microtime(true) * 1000)),
400400
];
401401

402402
$this->collection->insertOne($message);

tests/QueueTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,11 +482,11 @@ public function resetStuck()
482482
//sets to running
483483
$this->collection->updateOne(
484484
['payload.key' => 0],
485-
['$set' => ['running' => true, 'resetTimestamp' => new \MongoDB\BSON\UTCDateTime(microtime(true) * 1000)]]
485+
['$set' => ['running' => true, 'resetTimestamp' => new \MongoDB\BSON\UTCDateTime((int)(microtime(true) * 1000))]]
486486
);
487487
$this->collection->updateOne(
488488
['payload.key' => 1],
489-
['$set' => ['running' => true, 'resetTimestamp' => new \MongoDB\BSON\UTCDateTime(microtime(true) * 1000)]]
489+
['$set' => ['running' => true, 'resetTimestamp' => new \MongoDB\BSON\UTCDateTime((int)(microtime(true) * 1000))]]
490490
);
491491

492492
$this->assertSame(2, $this->collection->count(['running' => true]));

0 commit comments

Comments
 (0)