-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Double file size validation when file is beyond the 'upload_max_filesize' parameter #32045
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
The fact that the message is not translated looks like a bug to me. Can you check in the profiler if it reports any missing translation? Though I wonder why the size constraint is triggered at all. If the file cannot be uploaded, this shouldn't happen. |
That the filesize check is not listed in the validator panel is expected as that error is caught on the form level and attached as an error to the form without using the validator component. I am not sure how we would solve the |
hi Xabbuh. So, what's your suggestion? I can try to debug this tomorrow. Why FileType doesn't use the public constants of File for translations? How to pass the translator object to the file type? The translator object is null, that's why the message isn't translated. Someone had the same the same problem : |
…(xabbuh) This PR was merged into the 3.4 branch. Discussion ---------- [FrameworkBundle] tag the FileType service as a form type | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | part of #32045 | License | MIT | Doc PR | In #30961 we undeprecated the `form.type.file` service as we need to pass the translator to the form type. But we forgot to add back the `form.type` tag which means that the form registry actually never used our service but instantiated the `FileType` itself and thus the type was never able to use a translator. Commits ------- ea5b1f4 tag the FileType service as a form type
@xabbuh there is also an error in the translation domain : Should be :
in FileType.php. I have tested and it works now with this last fix. |
This PR was merged into the 3.4 branch. Discussion ---------- [Form] fix translation domain | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #32045 (comment) | License | MIT | Doc PR | Commits ------- 74387cf fix translation domain
@COil Did you find a workaround for the duplicated error message? I can reproduce this. |
No. :) As it's not critical. But may be you can change the 'upload_max_filesize' on the fly just for the action. |
Just a comment, obviously we can't change the upload_max_filesize ini setting at runtime so this trick will not function. |
Hello, Got duplicate error message too. This is confusing for the user i think, If i limit the image to 2mo, users does not have to know my upload_max_filesize value. The only case is when the upload_max_filesize value is lower than maxSize. |
Can you please check if #39119 fixes this? |
…mits (xabbuh) This PR was merged into the 4.4 branch. Discussion ---------- [Form] prevent duplicated error message for file upload limits | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #32045, #36503, #39107 | License | MIT | Doc PR | Commits ------- fe6a2dd prevent duplicated error message for file upload limits
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected: 4.3.1
Description
I have a double file size validation when file is beyond the 'upload_max_filesize' parameter.
In this case the max size is set to 500ko in the form and the max size allowed by php 2mo. Additionally the error message isn't translated.
How to reproduce
and php setting :
upload_max_filesize | 2M | 2M
Possible Solution
Detect if a maxSize constraint already exists and is below the upload_max_filesize value?
See you. COil.
The text was updated successfully, but these errors were encountered: