Skip to content

Commit f07345b

Browse files
committed
Fix dropping search index
Error Cannot use object of type stdClass as array
1 parent 6af8698 commit f07345b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/Doctrine/ODM/MongoDB/SchemaManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ public function updateDocumentSearchIndexes(string $documentName): void
413413

414414
$definedNames = array_column($searchIndexes, 'name');
415415
try {
416-
$existingNames = array_column(iterator_to_array($collection->listSearchIndexes()), 'name');
416+
$existingNames = array_column(iterator_to_array($collection->listSearchIndexes(['typeMap' => ['root' => 'array']])), 'name');
417417
} catch (CommandException $e) {
418418
/* If $listSearchIndexes doesn't exist, only throw if search indexes have been defined.
419419
* If no search indexes are defined and the server doesn't support search indexes, there's
@@ -465,7 +465,7 @@ public function deleteDocumentSearchIndexes(string $documentName): void
465465
$collection = $this->dm->getDocumentCollection($class->name);
466466

467467
try {
468-
$searchIndexes = $collection->listSearchIndexes();
468+
$searchIndexes = $collection->listSearchIndexes(['typeMap' => ['root' => 'array']]);
469469
} catch (CommandException $e) {
470470
// If the server does not support search indexes, there are no indexes to remove in any case
471471
if ($this->isSearchIndexCommandException($e)) {

psalm-baseline.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,12 @@
184184
<code><![CDATA[array]]></code>
185185
</LessSpecificImplementedReturnType>
186186
</file>
187+
<file src="lib/Doctrine/ODM/MongoDB/SchemaManager.php">
188+
<InvalidArgument>
189+
<code><![CDATA[['typeMap' => ['root' => 'array']]]]></code>
190+
<code><![CDATA[['typeMap' => ['root' => 'array']]]]></code>
191+
</InvalidArgument>
192+
</file>
187193
<file src="lib/Doctrine/ODM/MongoDB/Tools/Console/Command/ClearCache/MetadataCommand.php">
188194
<UndefinedInterfaceMethod>
189195
<code><![CDATA[getDocumentManager]]></code>

0 commit comments

Comments
 (0)