Skip to content

Commit

Permalink
Fix dropping search index
Browse files Browse the repository at this point in the history
Error Cannot use object of type stdClass as array
  • Loading branch information
GromNaN committed Oct 14, 2024
1 parent 6af8698 commit 25c71c9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/MongoDB/SchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ public function updateDocumentSearchIndexes(string $documentName): void

$definedNames = array_column($searchIndexes, 'name');
try {
$existingNames = array_column(iterator_to_array($collection->listSearchIndexes()), 'name');
$existingNames = array_column(iterator_to_array($collection->listSearchIndexes(['typeMap' => ['root' => 'array']])), 'name');

Check failure on line 416 in lib/Doctrine/ODM/MongoDB/SchemaManager.php

View workflow job for this annotation

GitHub Actions / Static Analysis with Psalm (8.2)

InvalidArgument

lib/Doctrine/ODM/MongoDB/SchemaManager.php:416:92: InvalidArgument: Argument 1 of MongoDB\Collection::listSearchIndexes expects array{name?: string}, but array{typeMap: array{root: 'array'}} with additional array shape fields (typeMap) was provided (see https://psalm.dev/004)
} catch (CommandException $e) {
/* If $listSearchIndexes doesn't exist, only throw if search indexes have been defined.
* If no search indexes are defined and the server doesn't support search indexes, there's
Expand Down Expand Up @@ -465,7 +465,7 @@ public function deleteDocumentSearchIndexes(string $documentName): void
$collection = $this->dm->getDocumentCollection($class->name);

try {
$searchIndexes = $collection->listSearchIndexes();
$searchIndexes = $collection->listSearchIndexes(['typeMap' => ['root' => 'array']]);

Check failure on line 468 in lib/Doctrine/ODM/MongoDB/SchemaManager.php

View workflow job for this annotation

GitHub Actions / Static Analysis with Psalm (8.2)

InvalidArgument

lib/Doctrine/ODM/MongoDB/SchemaManager.php:468:61: InvalidArgument: Argument 1 of MongoDB\Collection::listSearchIndexes expects array{name?: string}, but array{typeMap: array{root: 'array'}} with additional array shape fields (typeMap) was provided (see https://psalm.dev/004)
} catch (CommandException $e) {
// If the server does not support search indexes, there are no indexes to remove in any case
if ($this->isSearchIndexCommandException($e)) {
Expand Down

0 comments on commit 25c71c9

Please sign in to comment.