Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:4.4fromxabbuh:issue-32045
Nov 27, 2020

Conversation

@xabbuh
Copy link
Member

QA
Branch?4.4
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix#32045,#36503,#39107
LicenseMIT
Doc PR

@thewalkingcoder
Copy link

@xabbuh thanks for your pull request, as expected i try with context#39107 same issue for me.

image

@xabbuh
Copy link
MemberAuthor

Thank you for the feedback. Could you create a small example application that allows me to reproduce and debug the issue?

@thewalkingcoder
Copy link

@xabbuh ok i try to create that today.

xabbuh reacted with thumbs up emoji

@thewalkingcoder
Copy link

@xabbuh
you can try here ;-)
https://github.com/thewalkingcoder/uploadfile

xabbuh reacted with thumbs up emoji


// Only add the error if the form is synchronized
if ($this->acceptsErrors($scope)) {
if (File::TOO_LARGE_ERROR ===$violation->getCode()) {
Copy link
Member

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

Copy link
MemberAuthor

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 theFile constraint we could potentially remove an error here that we would have to keep.

@xabbuh
Copy link
MemberAuthor

Status: Needs work

@xabbuh
Copy link
MemberAuthor

@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?

thewalkingcoder reacted with thumbs up emoji

@xabbuh
Copy link
MemberAuthor

Status: Needs Review

thewalkingcoder reacted with thumbs up emoji

@thewalkingcoder
Copy link

@xabbuh thanks for your works.

Your commit resolve the duplicated message and so resolve#39107
image

but if i remove

uploadIniSizeErrorMessage
/**     * @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

image

normally is

Custom message max size.

other issue ? or side effect with the PR ?

@xabbuh
Copy link
MemberAuthor

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 theFileValidator will not perform any additional checks.

@thewalkingcoder
Copy link

thewalkingcoder commentedNov 21, 2020
edited
Loading

@xabbuh i say just i don't understand the behaviour

configvalue
php.ini2mo
Assert maxSize500ko
Assert maxSizeMessageCustom Max file 500ko
Assert uploadIniSizeErrorMessageCustom message Max file php ini
file.pdf6mo
resultCustom message Max file php ini

for me this PR resolve duplicated error Message.

but if i remove Assert uploadIniSizeErrorMessage

configvalue
php.ini2mo
Assert maxSize500ko
Assert maxSizeMessageCustom Max file 500ko size
file.pdf6mo
resultthe file is too large. Allowed maximum size is 0.5Mo

default message maxSize is applied instead MaxSizeMessage

For me, the expected behaviour is

configvalue
php.ini2mo
Assert maxSize500ko
file.pdf6mo
resultthe file is too large. Allowed maximum size is 0.5Mo (default message Assert MaxSize)
behaviourok actually
configvalue
php.ini2mo
Assert maxSize500ko
Assert maxSizeMessageCustom Max file 500ko size
file.pdf6mo
resultCustom Max file 500ko size (custom message with maxSizeMessage)
behaviournot the same actually
configvalue
php.ini2mo
Assert maxSize500ko
Assert maxSizeMessageCustom Max file 500ko size
Assert uploadIniSizeErrorMessageCustom message Max file php ini
file.pdf6mo
resultCustom Max file 500ko size (custom message with maxSizeMessage)
behaviournot the same actually
configvalue
php.ini2mo
Assert uploadIniSizeErrorMessageCustom message Max file php ini
Assert maxSize4mo
file.pdf6mo
resultCustom message Max file php ini (custom message with uploadIniSizeErrorMessage)
behaviourok actually

I'm not sure is a side effect with this PR

@xabbuh
Copy link
MemberAuthor

Well, if the file exceeds the limit configured withupload_max_filesize theuploadIniSizeErrorMessage is used. If you do not configure it explicitly, its default valueThe file is too large. Allowed maximum size is {{ limit }} {{ suffix }}. will be used. The message configured withmaxSizeMessage is only taken into account if the file size is below the limit configured withupload_max_filesize, but exceeds themaxSize value of theFile constraint. So the results that you observe look expected to me.

thewalkingcoder reacted with thumbs up emoji

@fabpot
Copy link
Member

Thank you@xabbuh.

COil reacted with thumbs up emoji

@fabpotfabpot merged commit66e76d1 intosymfony:4.4Nov 27, 2020
@xabbuhxabbuh deleted the issue-32045 branchNovember 27, 2020 08:05
This was referencedNov 29, 2020
@COil
Copy link
Contributor

COil commentedDec 5, 2020

Hi, I can confirm it is fixed in 5.1.9. Thank you.

xabbuh reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@stofstofstof left review comments

@fabpotfabpotfabpot approved these changes

@ycerutoycerutoyceruto approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

4.4

Development

Successfully merging this pull request may close these issues.

7 participants

@xabbuh@thewalkingcoder@fabpot@COil@stof@yceruto@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp