Skip to content

Commit

Permalink
Merge branch '7.1' into 7.2
Browse files Browse the repository at this point in the history
* 7.1:
  Ensure compatibility with ext-mongodb v2
  • Loading branch information
nicolas-grekas committed Oct 25, 2024
2 parents ec0e86b + 1b89839 commit 07212a5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Store/MongoDbStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use MongoDB\Database;
use MongoDB\Driver\BulkWrite;
use MongoDB\Driver\Command;
use MongoDB\Driver\Exception\WriteException;
use MongoDB\Driver\Exception\BulkWriteException;
use MongoDB\Driver\Manager;
use MongoDB\Driver\Query;
use MongoDB\Exception\DriverRuntimeException;
Expand Down Expand Up @@ -225,7 +225,7 @@ public function save(Key $key): void

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

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

private function isDuplicateKeyException(WriteException $e): bool
private function isDuplicateKeyException(BulkWriteException $e): bool
{
$code = $e->getCode();

Expand All @@ -355,7 +355,7 @@ private function getManager(): Manager
*/
private function createMongoDateTime(float $seconds): UTCDateTime
{
return new UTCDateTime($seconds * 1000);
return new UTCDateTime((int) ($seconds * 1000));
}

/**
Expand Down

0 comments on commit 07212a5

Please sign in to comment.