Skip to content

Commit 511a476

Browse files
authored
Gracefully handle search index exceptions on non MongoDB Atlas (#2673)
* Gracefully handle search index exceptions on non MongoDB Atlas * Fix php Coding Standards pipeline
1 parent 10ec1da commit 511a476

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/Doctrine/ODM/MongoDB/SchemaManager.php

+5
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,11 @@ private function isSearchIndexCommandException(CommandException $e): bool
10621062
return true;
10631063
}
10641064

1065+
// MongoDB 6.0.7+ and 7.0+: "$listSearchIndexes stage is only allowed on MongoDB Atlas"
1066+
if ($e->getMessage() === '$listSearchIndexes stage is only allowed on MongoDB Atlas') {
1067+
return true;
1068+
}
1069+
10651070
// Older server versions don't support $listSearchIndexes
10661071
// We don't check for an error code here as the code is not documented and we can't rely on it
10671072
return str_contains($e->getMessage(), 'Unrecognized pipeline stage name: \'$listSearchIndexes\'');

0 commit comments

Comments
 (0)