Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Form] Use !isset for checks cause this doesn't falsely include 0 #41000

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

Merged
merged 1 commit into from
May 27, 2021

Conversation

KDederichs
Copy link
Contributor

Q A
Branch? 5.2
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #40999
License MIT

By using isset 0 won't falsely included anymore

@carsonbot carsonbot added this to the 5.2 milestone Apr 30, 2021
@derrabus derrabus added the Form label Apr 30, 2021
@carsonbot carsonbot changed the title Use !isset for checks cause this doesn't falsely include 0 [Form] Use !isset for checks cause this doesn't falsely include 0 Apr 30, 2021
@derrabus
Copy link
Member

Can you add a test for this issue?

Question: empty() also filters out empty strings while !isset() doesn't. Is this relevant here?

@Nyholm
Copy link
Member

Nyholm commented May 7, 2021

Excellent PR. Thank you.

If you add a small test for this I'll be happy to merge.

@KDederichs
Copy link
Contributor Author

Excellent PR. Thank you.

If you add a small test for this I'll be happy to merge.

I'm kinda waiting on a reply in the mentioned issue tbh.
Cause it's really only a bug in that specific usecase, which I'm not 100% sure should be valid anyways.

@KDederichs
Copy link
Contributor Author

Sorry took me a while to get to it but I got some tests that would fail without the changes on both PRs

@xabbuh
Copy link
Member

xabbuh commented May 17, 2021

This applies to 4.4 too, right?

@KDederichs
Copy link
Contributor Author

Yeah it's actually a thing in all symfony versions I think.

@derrabus derrabus modified the milestones: 5.2, 4.4 May 17, 2021
@@ -170,9 +170,9 @@ public function reverseTransform($value)
empty($value['year']) ? $this->referenceDate->format('Y') : $value['year'],
empty($value['month']) ? $this->referenceDate->format('m') : $value['month'],
empty($value['day']) ? $this->referenceDate->format('d') : $value['day'],
Copy link
Member

Choose a reason for hiding this comment

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

can you please ensure we have a test case using 0 for year+month+day?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added it as test for DateType.

@nicolas-grekas nicolas-grekas changed the base branch from 5.2 to 4.4 May 27, 2021 12:54
@nicolas-grekas
Copy link
Member

Thank you @KDederichs.

@nicolas-grekas nicolas-grekas merged commit 9b89b2e into symfony:4.4 May 27, 2021
This was referenced May 31, 2021
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.

8 participants