Skip to content

Commit

Permalink
Gracefully handle search index exceptions on non MongoDB Atlas (#2673)
Browse files Browse the repository at this point in the history
* Gracefully handle search index exceptions on non MongoDB Atlas

* Fix php Coding Standards pipeline
  • Loading branch information
Jafarili committed Sep 6, 2024
1 parent 10ec1da commit 511a476
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/Doctrine/ODM/MongoDB/SchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,11 @@ private function isSearchIndexCommandException(CommandException $e): bool
return true;
}

// MongoDB 6.0.7+ and 7.0+: "$listSearchIndexes stage is only allowed on MongoDB Atlas"
if ($e->getMessage() === '$listSearchIndexes stage is only allowed on MongoDB Atlas') {
return true;
}

// Older server versions don't support $listSearchIndexes
// We don't check for an error code here as the code is not documented and we can't rely on it
return str_contains($e->getMessage(), 'Unrecognized pipeline stage name: \'$listSearchIndexes\'');
Expand Down

0 comments on commit 511a476

Please sign in to comment.