-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] prevent duplicated error message for file upload limits #39119
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
Conversation
xabbuh
commented
Nov 19, 2020
Q | A |
---|---|
Branch? | 4.4 |
Bug fix? | yes |
New feature? | no |
Deprecations? | no |
Tickets | Fix #32045, #36503, #39107 |
License | MIT |
Doc PR |
Thank you for the feedback. Could you create a small example application that allows me to reproduce and debug the issue? |
@xabbuh ok i try to create that today. |
@xabbuh |
@@ -124,6 +126,17 @@ public function mapViolation(ConstraintViolation $violation, FormInterface $form | |||
|
|||
// Only add the error if the form is synchronized | |||
if ($this->acceptsErrors($scope)) { | |||
if (File::TOO_LARGE_ERROR === $violation->getCode()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a better check could be $violation->getCause() instanceof File
to account for the different error codes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. If there are multiple file upload files and one of them fails with another check of the File
constraint we could potentially remove an error here that we would have to keep.
Status: Needs work |
@thewalkingcoder Thanks, based on your example I was able to find a few issue with my initial solution. Can you try the updated patch again? |
Status: Needs Review |
@xabbuh thanks for your works. Your commit resolve the duplicated message and so resolve #39107 but if i remove
/**
* @var array<UploadedFile>
* @Assert\NotBlank(message="Veuillez sélectionner un fichier.")
* @Assert\All({
* @Assert\File(
* maxSize = "500k",
* maxSizeMessage = "Custom message max size.",
* uploadFormSizeErrorMessage = "Custom message max size form",
* )
* })
*/
public $files; error message is normally is
other issue ? or side effect with the PR ? |
If I understand you correctly, that's expected. The file couldn't be uploaded as the maximum file limit configured for PHP is reached and thus the |
@xabbuh i say just i don't understand the behaviour
for me this PR resolve duplicated error Message. but if i remove Assert uploadIniSizeErrorMessage
default message maxSize is applied instead MaxSizeMessage For me, the expected behaviour is
I'm not sure is a side effect with this PR |
Well, if the file exceeds the limit configured with |
Thank you @xabbuh. |
Hi, I can confirm it is fixed in 5.1.9. Thank you. |