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

Skip to content

[Form] Fixed #11675 ValueToDuplicatesTransformer accept "0" value #11676

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

Closed
wants to merge 1 commit into from

Conversation

Nek-
Copy link
Contributor

@Nek- Nek- commented Aug 15, 2014

Q A
Bug fix? [yes]
New feature? [no]
BC breaks? [no]
Deprecations? [no]
Tests pass? [yes]
Fixed tickets #11675
License MIT

@@ -64,7 +64,7 @@ public function reverseTransform($array)
$emptyKeys = array();

foreach ($this->keys as $key) {
if (!empty($array[$key])) {
if (isset($array[$key]) && $array[$key] !== null && $array[$key] !== '' && $array !== false) {
Copy link
Member

Choose a reason for hiding this comment

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

what about empty arrays as values ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch. I'm gonna add this test.

Copy link
Contributor

Choose a reason for hiding this comment

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

isset($array[$key]) && $array[$key] !== null is basically the same thing (isset returns false if the key $key is null)

Copy link
Member

Choose a reason for hiding this comment

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

@Taluu not exactly the same. isset($array[$key]) covers more cases that $array[$key] !== null. It covers null values, but not missing values. So $array[$key] !== null is indeed not necessary here, but both conditions are not the same thing.

@Nek- please also switch the order of operands for each condition. We are using Yoda conditions in Symfony

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

@stof Yup, that's what I meant (the null comparision is done by the isset verification). My bad if there was a misunderstanding. :)

@stof
Copy link
Member

stof commented Aug 18, 2014

note to maintainers: the fix should be merged to 2.3

Fixed wrong return null syntax

Added transformation to null on empty arrays

Removed useless statement in condition and switched to yoda condition
@stof
Copy link
Member

stof commented Aug 18, 2014

👍

@stof stof added the Form label Aug 18, 2014
@webmozart
Copy link
Contributor

Good catch, thanks Maxime.

webmozart added a commit that referenced this pull request Aug 19, 2014
…" value (Nek-)

This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #11676).

Discussion
----------

[Form] Fixed #11675 ValueToDuplicatesTransformer accept "0" value

| Q             | A
| ------------- | ---
| Bug fix?      | [yes]
| New feature?  | [no]
| BC breaks?    | [no]
| Deprecations? | [no]
| Tests pass?   | [yes]
| Fixed tickets | #11675
| License       | MIT

Commits
-------

31d48ab Fixed #11675 ValueToDuplicatesTransformer accept "0" value
@webmozart webmozart added the Bug label Aug 19, 2014
@romainneutron
Copy link
Contributor

👍

@webmozart webmozart closed this Aug 19, 2014
@Nek- Nek- deleted the ticket_11675 branch August 19, 2014 09:07
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.

5 participants