Skip to content

Commit 1b89839

Browse files
committedOct 25, 2024
Merge branch '6.4' into 7.1
* 6.4: Ensure compatibility with ext-mongodb v2
2 parents 091a6ff + a69c3dd commit 1b89839

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
 

‎Store/MongoDbStore.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use MongoDB\Database;
1818
use MongoDB\Driver\BulkWrite;
1919
use MongoDB\Driver\Command;
20-
use MongoDB\Driver\Exception\WriteException;
20+
use MongoDB\Driver\Exception\BulkWriteException;
2121
use MongoDB\Driver\Manager;
2222
use MongoDB\Driver\Query;
2323
use MongoDB\Exception\DriverRuntimeException;
@@ -225,7 +225,7 @@ public function save(Key $key): void
225225

226226
try {
227227
$this->upsert($key, $this->initialTtl);
228-
} catch (WriteException $e) {
228+
} catch (BulkWriteException $e) {
229229
if ($this->isDuplicateKeyException($e)) {
230230
throw new LockConflictedException('Lock was acquired by someone else.', 0, $e);
231231
}
@@ -249,7 +249,7 @@ public function putOffExpiration(Key $key, float $ttl): void
249249

250250
try {
251251
$this->upsert($key, $ttl);
252-
} catch (WriteException $e) {
252+
} catch (BulkWriteException $e) {
253253
if ($this->isDuplicateKeyException($e)) {
254254
throw new LockConflictedException('Failed to put off the expiration of the lock.', 0, $e);
255255
}
@@ -332,7 +332,7 @@ private function upsert(Key $key, float $ttl): void
332332
$this->getManager()->executeBulkWrite($this->namespace, $write);
333333
}
334334

335-
private function isDuplicateKeyException(WriteException $e): bool
335+
private function isDuplicateKeyException(BulkWriteException $e): bool
336336
{
337337
$code = $e->getCode();
338338

@@ -355,7 +355,7 @@ private function getManager(): Manager
355355
*/
356356
private function createMongoDateTime(float $seconds): UTCDateTime
357357
{
358-
return new UTCDateTime($seconds * 1000);
358+
return new UTCDateTime((int) ($seconds * 1000));
359359
}
360360

361361
/**

0 commit comments

Comments
 (0)
Failed to load comments.