Skip to content

Improve the 'post_max_size_message' for form that don't include file uploads. #35011

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
stefanospetrakis opened this issue Dec 17, 2019 · 10 comments

Comments

@stefanospetrakis
Copy link

Symfony version(s) affected
All

Description
When POST-ing a form that exceeds the post_max_size limit of PHP, the Symfony validation message should not be exclusively about file uploads, since we can have forms submitted without any file uploads, which could lead to confusion.

Suggestion
Before: 'The uploaded file was too large. Please try to upload a smaller file.'
After: 'The combination of submitted content and uploaded files was too large. Please try to reduce the size of the submitted content or upload smaller files.'

Example

By setting php.ini to a really small value:

post_max_size=2

and submitting a form with a simple text field (TextType::class),

image

the resulting error is:

image

@carsonbot
Copy link

Thank you for this issue.
There has not been a lot of activity here for a while. Has this been resolved?

@stefanospetrakis
Copy link
Author

Nope, this has simply been dormant, it is still relevant AFAIK.

@carsonbot carsonbot removed the Stalled label Feb 19, 2021
@xabbuh
Copy link
Member

xabbuh commented Mar 6, 2021

I am not sure that we can do anything here without breaking BC. But there is the post_max_size_message option which you can customize. Isn't that sufficient enough?

@stefanospetrakis
Copy link
Author

That's good enough, but only after customizing.
I was referring to the out-of-the-box delivered text and its meaning.
How would it break BC?
My idea was to update this string:

'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.',

https://github.com/symfony/symfony/blob/5.x/src/Symfony/Component/Form/Extension/Core/Type/FormType.php#L201

@xabbuh
Copy link
Member

xabbuh commented Mar 6, 2021

Because people may rely on the current wording (in tests for example).

@stefanospetrakis
Copy link
Author

Ok, I can see how that may play out.
But then, your point is that due to possible breaking BC in external code, this wording will stay there for a good amount of time?

@xabbuh
Copy link
Member

xabbuh commented Mar 9, 2021

I think so yes. Given that making the transition in a BC way is quite difficult and the fact that the message is already customizable I don't expect anything to change here to be honest.

@carsonbot
Copy link

Thank you for this issue.
There has not been a lot of activity here for a while. Has this been resolved?

@carsonbot
Copy link

Friendly ping? Should this still be open? I will close if I don't hear anything.

@carsonbot
Copy link

Hey,

I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants