1717use MongoDB \Database ;
1818use MongoDB \Driver \BulkWrite ;
1919use MongoDB \Driver \Command ;
20- use MongoDB \Driver \Exception \WriteException ;
20+ use MongoDB \Driver \Exception \BulkWriteException ;
2121use MongoDB \Driver \Manager ;
2222use MongoDB \Driver \Query ;
2323use 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