-
-
Notifications
You must be signed in to change notification settings - Fork 513
PHPORM-356: Skip search indexes not enabled exception #2787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHPORM-356: Skip search indexes not enabled exception #2787
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test like other exceptions have:
mongodb-odm/tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php
Lines 432 to 451 in 6f4f0fb
public function testCreateDocumentSearchIndexesNotSupported(): void | |
{ | |
$exception = $this->createSearchIndexCommandException(); | |
$cmsArticleCollectionName = $this->dm->getClassMetadata(CmsArticle::class)->getCollection(); | |
foreach ($this->documentCollections as $collectionName => $collection) { | |
if ($collectionName === $cmsArticleCollectionName) { | |
$collection | |
->expects($this->once()) | |
->method('createSearchIndexes') | |
->with($this->anything()) | |
->willThrowException($exception); | |
} else { | |
$collection->expects($this->never())->method('createSearchIndexes'); | |
} | |
} | |
$this->expectExceptionObject($exception); | |
$this->schemaManager->createDocumentSearchIndexes(CmsArticle::class); | |
} |
@@ -47,6 +47,7 @@ final class SchemaManager | |||
|
|||
private const CODE_SHARDING_ALREADY_INITIALIZED = 23; | |||
private const CODE_COMMAND_NOT_SUPPORTED = 115; | |||
private const CODE_SEARCH_NOT_ENABLED = 31082; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be great to have this exposed as a const from one of underlying libs. Or is it still not exposed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, we have the same issue in the Laravel package: https://github.com/mongodb/laravel-mongodb/blob/a2b4ab86dfc9248050b2592d9830773ac335774e/src/Schema/Builder.php#L386-L395
But if we rely on a new function in the mongodb/mongodb
library, we would have to increase the minimum version for low benefits.
I'm tracking this request: PHPLIB-1689
67d3da4
to
d49a393
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once the comment is added.
If search indexes are not enabled on the server, we should simply skip any search index operation. This commit adds an error code to the search index error check already in place.
d49a393
to
2715d7c
Compare
If search indexes are not enabled on the server, we should simply skip any search index operation. This commit adds an error code to the search index error check already in place.
Closes PHPORM-356