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

Catch possible null value error in ModelFilter #1800

Merged
merged 1 commit into from
Apr 10, 2024

Conversation

core23
Copy link
Member

@core23 core23 commented Apr 1, 2024

Subject

I am targeting this branch, because is a patch.

Changelog

### Fixed
- Catch possible null value error in `ModelFilter`

Got the error when using the ModelFilter in combination with a ModelAutocompleteType.

The error might show up if you bookmark a link (e.g. /list?filter[user][value]=entityID123) and you than remove the referenced entity. The hasValue check passes, because you provide a valid value, but there is no entity so you receive a null error.

@core23 core23 added the bug label Apr 1, 2024
@core23 core23 requested review from jordisala1991 and VincentLanglet and removed request for jordisala1991 April 1, 2024 16:25
Copy link
Member

@VincentLanglet VincentLanglet left a comment

Choose a reason for hiding this comment

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

Are you able to add a functional test for this bug ?

@@ -147,6 +147,10 @@ private function buildInExpression(ProxyQueryInterface $query, string $alias, Fi
$orX = $queryBuilder->expr()->orX();

foreach ($data->getValue() as $value) {
if (null === $value) {
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't even safer to user if (!\is_object($value)) { ?
image

@VincentLanglet
Copy link
Member

You can rebase 4.x to fix the ci

@core23 core23 force-pushed the catch-null-error branch from cd95add to a9e3f31 Compare April 3, 2024 12:39
@core23 core23 force-pushed the catch-null-error branch from a9e3f31 to aa5de01 Compare April 3, 2024 14:57
@core23
Copy link
Member Author

core23 commented Apr 3, 2024

Done

@core23 core23 requested a review from VincentLanglet April 4, 2024 06:17
@VincentLanglet
Copy link
Member

Thanks, I dont have a computer until next week. It's on my todo to review/merge/release this

@VincentLanglet VincentLanglet merged commit 447231d into sonata-project:4.x Apr 10, 2024
30 checks passed
@core23 core23 deleted the catch-null-error branch April 10, 2024 14:20
@VincentLanglet
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants