-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form][Validation] Unique entity validator throw undefined index if no data is provided #23486
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
Comments
I am not sure how to reproduce your issue. Can you show the functional test that is triggering this? |
Can you please also investigate what exactly gets passed to |
Hello, $client->request(
'PUT',
$this->getUrl('api_put_article', ['id' => 1]),
[],
[],
['CONTENT_TYPE' => 'application/json'],
json_encode([]) // Empty array submitted
); The parameter |
I am sorry, but I still cannot reproduce your issue. Did you try the latest patch releases (line 137 that you mentioned in the issue description isn't the same in more recent releases)? If you still experience the issue then, can you please create a small example project that allows to reproduce your issue? |
Same issue here, Symfony 2.8.17 I get this issue when I do not submit the field in my fields-array of my unique entity annotation. So when its disabled in the form because its not needed in a case. |
Well, it would still be nice to have a small project that would allow to reproduce the issue. |
Hi ! Sorry for the delay, day off and week-end... :-) Here is a code reproducing the error : https://github.com/flohw/form_errors/ docker-compose build
docker-compose up -d
docker-compose exec php app/console doctrine:schema:create On Symfony version : 2.7.18 (installed with symfony installer, same as my original project). |
Hi ! Is there some updates here ? |
@flohw Sorry for not replying earlier. I have tried your project and the issue indeed is that you are using Symfony 2.8.17. Updating to 2.8.18 (and thus getting the changes from #21562 resolves it). I am closing here as the issue is already fixed. By the way, the fact that you were not able to update to 2.8.18 is related to the fact that your PHPUnit requirement is bound to |
Ok, I'll try to update phpunit too. Thanks for the hint ! :-) |
The UniqueEntityValidator throw an "undefined index error" when submitting no data or null value on a defined entity's field.
My entity has
UniqueEntity(fields={"reference", "supplier"})
constraint.In my functional test I submit an empty array as post data.
The response is "Undefined index: reference".
After some research, the bug was introduced here symfony/doctrine-bridge@40941a3#diff-e59b775599f36ee1318299634bc1be79 when line 88 has been splitted.
In my exemple
$criteria['reference']
does not exist any more and the error (undefined index) occurs on line 137If
$criteria[$fieldName] = $fieldValue;
were between line 88 and 90 it would works properly.Sorry but I am not sure about the solution and don't know how to create a test for this case. If someone can help me about that.
Thank you.
Curiosity question : is there a reason to use
ClassMetdata
attributes (likereflFields
) to get field values instead ofgetFieldValue($entity, $field)
method?The text was updated successfully, but these errors were encountered: