Skip to content

Commit 9cc8291

Browse files
authored
Catch BulkWriteException, since WriteException is removed from ext-mongodb 2.0 (#2770)
1 parent a07b902 commit 9cc8291

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
use MongoDB\BSON\ObjectId;
3434
use MongoDB\Collection;
3535
use MongoDB\Driver\CursorInterface;
36+
use MongoDB\Driver\Exception\BulkWriteException;
3637
use MongoDB\Driver\Exception\Exception as DriverException;
37-
use MongoDB\Driver\Exception\WriteException;
3838
use MongoDB\Driver\Session;
3939
use MongoDB\Driver\WriteConcern;
4040
use MongoDB\GridFS\Bucket;
@@ -266,7 +266,7 @@ public function executeUpserts(array $options = []): void
266266
$this->executeUpsert($document, $options);
267267
$this->handleCollections($document, $options);
268268
unset($this->queuedUpserts[$oid]);
269-
} catch (WriteException $e) {
269+
} catch (BulkWriteException $e) {
270270
unset($this->queuedUpserts[$oid]);
271271

272272
throw $e;
@@ -338,7 +338,7 @@ private function executeUpsert(object $document, array $options): void
338338
$this->collection->updateOne($criteria, $data, $options);
339339

340340
return;
341-
} catch (WriteException $e) {
341+
} catch (BulkWriteException $e) {
342342
if (empty($retry) || strpos($e->getMessage(), 'Mod on _id not allowed') === false) {
343343
throw $e;
344344
}

0 commit comments

Comments
 (0)