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 f07345b
Show file tree
Hide file tree
Showing 2 changed files with 8 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');
} 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']]);
} 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
6 changes: 6 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@
<code><![CDATA[array]]></code>
</LessSpecificImplementedReturnType>
</file>
<file src="lib/Doctrine/ODM/MongoDB/SchemaManager.php">
<InvalidArgument>
<code><![CDATA[['typeMap' => ['root' => 'array']]]]></code>
<code><![CDATA[['typeMap' => ['root' => 'array']]]]></code>
</InvalidArgument>
</file>
<file src="lib/Doctrine/ODM/MongoDB/Tools/Console/Command/ClearCache/MetadataCommand.php">
<UndefinedInterfaceMethod>
<code><![CDATA[getDocumentManager]]></code>
Expand Down

0 comments on commit f07345b

Please sign in to comment.