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 ;
@@ -225,7 +225,7 @@ public function save(Key $key): void
225225
226226 try {
227227 $ this ->upsert ($ key , $ this ->initialTtl );
228- } catch (WriteException $ e ) {
228+ } catch (BulkWriteException $ e ) {
229229 if ($ this ->isDuplicateKeyException ($ e )) {
230230 throw new LockConflictedException ('Lock was acquired by someone else. ' , 0 , $ e );
231231 }
@@ -249,7 +249,7 @@ public function putOffExpiration(Key $key, float $ttl): void
249249
250250 try {
251251 $ this ->upsert ($ key , $ ttl );
252- } catch (WriteException $ e ) {
252+ } catch (BulkWriteException $ e ) {
253253 if ($ this ->isDuplicateKeyException ($ e )) {
254254 throw new LockConflictedException ('Failed to put off the expiration of the lock. ' , 0 , $ e );
255255 }
@@ -332,7 +332,7 @@ private function upsert(Key $key, float $ttl): void
332332 $ this ->getManager ()->executeBulkWrite ($ this ->namespace , $ write );
333333 }
334334
335- private function isDuplicateKeyException (WriteException $ e ): bool
335+ private function isDuplicateKeyException (BulkWriteException $ e ): bool
336336 {
337337 $ code = $ e ->getCode ();
338338
@@ -355,7 +355,7 @@ private function getManager(): Manager
355355 */
356356 private function createMongoDateTime (float $ seconds ): UTCDateTime
357357 {
358- return new UTCDateTime ($ seconds * 1000 );
358+ return new UTCDateTime (( int ) ( $ seconds * 1000 ) );
359359 }
360360
361361 /**
0 commit comments