Skip to content
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

Fix "Cannot use object of type stdClass as array" in search index drop #2689

Merged
merged 1 commit into from
Oct 14, 2024

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Oct 14, 2024

Q A
Type bug
BC Break no
Fixed issues fix #2684

Summary

The typeMap option from the Collection instance is not inherited (bug report PHPLIB-1548).

This was not detected by unit tests as the call to Collection::listSearchIndexes() is mocked.

public function testUpdateDocumentSearchIndexes(): void
{
$collectionName = $this->dm->getClassMetadata(CmsArticle::class)->getCollection();
$collection = $this->documentCollections[$collectionName];
$collection
->expects($this->once())
->method('listSearchIndexes')
->willReturn(new ArrayIterator([
['name' => 'default'],
['name' => 'foo'],
]));

@GromNaN GromNaN requested a review from alcaeus October 14, 2024 08:54
@GromNaN GromNaN changed the title Fix "Error Cannot use object of type stdClass as array" in search index management Fix "Cannot use object of type stdClass as array" in search index management Oct 14, 2024
@GromNaN GromNaN changed the title Fix "Cannot use object of type stdClass as array" in search index management Fix "Cannot use object of type stdClass as array" in search index drop Oct 14, 2024
@GromNaN GromNaN added this to the 2.9.1 milestone Oct 14, 2024
@GromNaN GromNaN added the Bug label Oct 14, 2024
Copy link
Member

@alcaeus alcaeus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change LGTM, but we should add a note that we can drop this once we bump the version requirement to the version that fixes this.

@alcaeus
Copy link
Member

alcaeus commented Oct 14, 2024

Note: the PHPStan errors suggest that we need to change the @param annotation for listSearchIndexes as well - it should read {name?: string, ...} to allow extra elements in the options array.

@GromNaN
Copy link
Member Author

GromNaN commented Oct 14, 2024

Note: the PHPStan errors suggest that we need to change the @param annotation for listSearchIndexes as well - it should read {name?: string, ...} to allow extra elements in the options array.

Done in mongodb/mongo-php-library#1480. I'll add this to the baseline for the time being.

Surprisingly, phpstan doesn't care.

@GromNaN GromNaN force-pushed the fix-drop-search-index branch from 25c71c9 to f07345b Compare October 14, 2024 11:16
Error Cannot use object of type stdClass as array
@GromNaN GromNaN force-pushed the fix-drop-search-index branch from f07345b to 2ec1204 Compare October 14, 2024 11:19
@GromNaN GromNaN merged commit 8ac8b3a into doctrine:2.9.x Oct 14, 2024
16 checks passed
@GromNaN GromNaN deleted the fix-drop-search-index branch October 14, 2024 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants