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 criteria mapping type #2610

Merged
merged 2 commits into from Feb 28, 2024
Merged

Conversation

franmomu
Copy link
Contributor

Q A
Type bug
BC Break no
Fixed issues

Summary

While doing #2596, the SA tool complained about the type of this property. For example in

* @ODM\ReferenceMany(targetDocument=Comment::class, mappedBy="parent", criteria={"isByAdmin"=true}, sort={"date"="desc"})

$criteria is holding an array that contains a boolean.

It is used in

$criteria = $this->cm->merge(
['_id' => ['$in' => array_values($ids)]],
$this->dm->getFilterCollection()->getFilterCriteria($class),
$mapping['criteria'] ?? [],
);
$criteria = $this->uow->getDocumentPersister($className)->prepareQueryOrNewObj($criteria);

and
$criteria = $this->cm->merge(
[$mappedByFieldName => $ownerClass->getIdentifierObject($owner)],
$this->dm->getFilterCollection()->getFilterCriteria($targetClass),
$mapping['criteria'] ?? [],
);

so it looks like it could contain any type, not only strings.

Ref: https://github.com/doctrine/mongodb-odm/pull/2596/files#r1441864943

@franmomu franmomu added the Bug label Feb 11, 2024
@franmomu franmomu added this to the 2.6.3 milestone Feb 11, 2024
Copy link
Member

@malarzm malarzm left a comment

Choose a reason for hiding this comment

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

Good catch! There's new PHPStan complaint tho :D

These new issues have been reported in vimeo/psalm#10578
@franmomu
Copy link
Contributor Author

Good catch! There's new PHPStan complaint tho :D

I've ignored the complaint since it has been reported in vimeo/psalm#10578

@franmomu franmomu merged commit 58c2b1f into doctrine:2.6.x Feb 28, 2024
16 checks passed
@franmomu franmomu deleted the fix_criteria_type branch February 28, 2024 22:36
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.

None yet

3 participants