Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cd3b778

Browse filesBrowse files
committed
Ensure compatibility with ext-mongodb v2
1 parent 948f55e commit cd3b778
Copy full SHA for cd3b778

File tree

1 file changed

+5
-5
lines changed
Filter options

1 file changed

+5
-5
lines changed

‎src/Symfony/Component/Lock/Store/MongoDbStore.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Store/MongoDbStore.php
+5-5Lines changed: 5 additions & 5 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.