Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Serializer] [ObjectNormalizer] Use bool filter when FILTER_BOOL is set#57541

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

mazumba-nx
Copy link

QA
Branch?7.1
Bug fix?yes
New feature?no
Deprecations?no
IssuesFix#57540
LicenseMIT

With 7.1 it is possible to map query booleans to php bool parameters (https://symfony.com/blog/new-in-symfony-7-1-misc-improvements-part-3#mapping-boolean-query-string-parameters). But as we found out, this only works when the DTO is initialized viaconstruct. Otherwise theFILTER_BOOL flag will be ignored and e.g. "false" will be deserialized astrue.

To fix this, I suggest to look for theFILTER_BOOL in the context and apply the filter, when the type isbool and the data isstring.

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has acontribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.2 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

Copy link
Member

@xabbuhxabbuh left a comment

Choose a reason for hiding this comment

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

LGTM

mazumba-nx reacted with heart emoji
@nicolas-grekasnicolas-grekasforce-pushed thebugfix-handle-bool-properties-in-resolver branch fromd2a2cbd to6e657e8CompareJune 28, 2024 07:42
@nicolas-grekas
Copy link
Member

Thank you@mazumba-nx.

mazumba-nx reacted with heart emoji

@nicolas-grekasnicolas-grekas merged commit0af0679 intosymfony:7.1Jun 28, 2024
8 of 9 checks passed
@fabpotfabpot mentioned this pull requestJun 28, 2024
nicolas-grekas added a commit that referenced this pull requestJan 17, 2025
…ER_BOOL (DjordyKoert)This PR was submitted for the 7.2 branch but it was squashed and merged into the 7.1 branch instead.Discussion----------[Serializer] [ObjectNormalizer] Filter int when using FILTER_BOOL| Q             | A| ------------- | ---| Branch?       | 7.2| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Issues        | Fix ...| License       | MITImproves on#57541 to also allow numeric values `1` and `0` with `FILTER_BOOL => true`Currently attempting to use the Serializer component to deserialize to deserialize a `1` or `0` result in the following error:```The type of the "booleanProperty" attribute for class "App\MyDTO" must be one of "bool" ("int" given).```Commits-------5288eba [Serializer] [ObjectNormalizer] Filter int when using FILTER_BOOL
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@OskarStarkOskarStarkOskarStark left review comments

@xabbuhxabbuhxabbuh approved these changes

@dunglasdunglasAwaiting requested review from dunglasdunglas is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
7.1
Development

Successfully merging this pull request may close these issues.

5 participants
@mazumba-nx@carsonbot@nicolas-grekas@OskarStark@xabbuh

[8]ページ先頭

©2009-2025 Movatter.jp