diff --git a/src/Symfony/Component/Lock/Store/MongoDbStore.php b/src/Symfony/Component/Lock/Store/MongoDbStore.php index c4a20e800776f..22c9bb63350f1 100644 --- a/src/Symfony/Component/Lock/Store/MongoDbStore.php +++ b/src/Symfony/Component/Lock/Store/MongoDbStore.php @@ -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; @@ -236,7 +236,7 @@ public function save(Key $key) 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); } @@ -262,7 +262,7 @@ public function putOffExpiration(Key $key, float $ttl) 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); } @@ -348,7 +348,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(); @@ -371,7 +371,7 @@ private function getManager(): Manager */ private function createMongoDateTime(float $seconds): UTCDateTime { - return new UTCDateTime($seconds * 1000); + return new UTCDateTime((int) ($seconds * 1000)); } /**