Skip to content

[Form] Broken validation ChoiceType with query_builder #15642

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
DmitriiBezborodnikov opened this issue Aug 28, 2015 · 4 comments
Closed

[Form] Broken validation ChoiceType with query_builder #15642

DmitriiBezborodnikov opened this issue Aug 28, 2015 · 4 comments

Comments

@DmitriiBezborodnikov
Copy link

// Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader.php
    public function getEntitiesByIds($identifier, array $values)
    {
         //...
         if (in_array($metadata->getTypeOfField($identifier), array('integer', 'bigint', 'smallint'))) {
            $parameterType = Connection::PARAM_INT_ARRAY;

            // Filter out non-integer values (e.g. ""). If we don't, some
            // databases such as PostgreSQL fail.
            $values = array_values(array_filter($values, function ($v) {
                return (string) $v === (string) (int) $v;
            }));
         } 
         //...
    }
}

On Windows (apache + php 32bit) bigint great 2147483647 always after (int) set to 2147483647: ((int) 2147483648) === 2147483647 // true

$values = array_values(array_filter($values, function ($v) {
                return (string) $v === (string) (int) $v;
            }));

Its clears $values great then 2147483647 and breaks the validation ChoiceType

@HeahDude
Copy link
Contributor

HeahDude commented Jul 8, 2016

@dkolzol Could you please confirm this bug still exists in latest releases. There had been many fixes since you've opened this ticket.

Thanks!

@DmitriiBezborodnikov
Copy link
Author

I confirm. The bug is present in the recent 2.8.8 release.

@xabbuh
Copy link
Member

xabbuh commented Jul 10, 2016

I am not sure if we can do anything here. In my opinion when using such big integer you need to ensure that your PHP version is able to deal with these data too.

@xabbuh
Copy link
Member

xabbuh commented Nov 12, 2016

see #20499

fabpot added a commit that referenced this issue Nov 22, 2016
This PR was merged into the 2.7 branch.

Discussion
----------

[Doctrine][Form] support large integers

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #15642
| License       | MIT
| Doc PR        | n/a

Commits
-------

6954a07 [Doctrine][Form] support large integers
@fabpot fabpot closed this as completed Nov 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants