Skip to content

Commit a69c3dd

Browse files
committedOct 25, 2024
Ensure compatibility with ext-mongodb v2
1 parent eb91b6c commit a69c3dd

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;
@@ -236,7 +236,7 @@ public function save(Key $key)
236236

237237
try {
238238
$this->upsert($key, $this->initialTtl);
239-
} catch (WriteException $e) {
239+
} catch (BulkWriteException $e) {
240240
if ($this->isDuplicateKeyException($e)) {
241241
throw new LockConflictedException('Lock was acquired by someone else.', 0, $e);
242242
}
@@ -262,7 +262,7 @@ public function putOffExpiration(Key $key, float $ttl)
262262

263263
try {
264264
$this->upsert($key, $ttl);
265-
} catch (WriteException $e) {
265+
} catch (BulkWriteException $e) {
266266
if ($this->isDuplicateKeyException($e)) {
267267
throw new LockConflictedException('Failed to put off the expiration of the lock.', 0, $e);
268268
}
@@ -348,7 +348,7 @@ private function upsert(Key $key, float $ttl): void
348348
$this->getManager()->executeBulkWrite($this->namespace, $write);
349349
}
350350

351-
private function isDuplicateKeyException(WriteException $e): bool
351+
private function isDuplicateKeyException(BulkWriteException $e): bool
352352
{
353353
$code = $e->getCode();
354354

@@ -371,7 +371,7 @@ private function getManager(): Manager
371371
*/
372372
private function createMongoDateTime(float $seconds): UTCDateTime
373373
{
374-
return new UTCDateTime($seconds * 1000);
374+
return new UTCDateTime((int) ($seconds * 1000));
375375
}
376376

377377
/**

0 commit comments

Comments
 (0)
Failed to load comments.