8000 [Form] [Doctrine-bridge] Wrong value transformation raises exception by egeloen · Pull Request #3727 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] [Doctrine-bridge] Wrong value transformation raises exception #3727

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
Closed

Conversation

egeloen
Copy link
@egeloen egeloen commented Mar 29, 2012

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #3446
Todo: Add a unit test

Steps

Calling Symfony\Component\Form\Extension\Core\DataTransformer\ChoicesToValuesTransformer::reverseTransform() with an empty array as a parameter, when the ChoicesToValuesTransformer::$choiceList is a Symfony\Bridge\Doctrine\Form\ChoiceList\EntityChoiceList.

Expected behavior

The method returns an empty array.

Observed behavior

A php warning is raised, thus throwing a 500 error

Warning: array_fill(): Number of elements must be positive in /var/www/widop/divosea.local/vendor/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtils.php line 127

Notes

I didn't write a test because I didn't know where to add it, as the ChoicesToValuesTransformer belongs to the Form component, and the EntityChoiceList belongs to the Doctrine bridge.

Also, all the unit test of ChoicesToValuesTransformer are made on a Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList, not all the classes implementing Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList. I think this could be improved so the tests would be more robust, maybe with a PHPUnit provider.

Thanks for your time :)

@clemherreman
Copy link
Contributor

I'd love to have this merged, one of my projects meets this bugs too.
ping @marcw

@stof
Copy link
Member
stof commented Apr 3, 2012

@bschussek ping

fabpot added a commit that referenced this pull request Apr 7, 2012
Commits
-------

a430f3d [#3446] [Form] Fix getChoicesForValues of EntityChoiceList on empty values

Discussion
----------

[Form] Fix reverseTransform on multiple entity form type

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #3446, #3727
Todo: -

---------------------------------------------------------------------------

by stof at 2012-04-03T23:05:55Z

@bschussek ping

---------------------------------------------------------------------------

by stof at 2012-04-03T23:06:45Z

This is an alternate implementation for #3727

---------------------------------------------------------------------------

by chmielot at 2012-04-04T13:47:27Z

OK, this is another possibility to fix this issue with working tests. What do you think about this?

---------------------------------------------------------------------------

by chmielot at 2012-04-04T13:51:27Z

OK, just done.

---------------------------------------------------------------------------

by stof at 2012-04-04T13:51:39Z

@beberlei @bschussek ping

---------------------------------------------------------------------------

by bschussek at 2012-04-06T18:50:37Z

@fabpot 👍
@webmozart webmozart closed this Apr 7, 2012
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.

5 participants
0