-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Forward Form::submit(Request) to Form::HandleRequest #16088
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
…eRequest When the argument of Form::submit is a Request object it forwards to Form::HandleRequest. Fixes the issue with uploaded files exceeding post_max_size, and form marked valid with empty fields.
|
I think the actual problem is that #11924 fixed the request handlers, but did not fix the legacy appraoch using the https://github.com/symfony/symfony/blob/2.8/src/Symfony/Component/Form/Extension/HttpFoundation/EventListener/BindRequestListener.php |
@@ -507,6 +508,10 @@ public function handleRequest($request = null) | |||
*/ | |||
public function submit($submittedData, $clearMissing = true) | |||
{ | |||
if ($submittedData instanceof Request) { | |||
return $this->handleRequest($submittedData); |
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.
this should be moved after the throw new AlreadySubmittedException
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.
also you need to skip the following code in this case because the request handler itself also calls submit
. see https://github.com/symfony/symfony/blob/2.8/src/Symfony/Component/Form/Extension/HttpFoundation/HttpFoundationRequestHandler.php#L116
so otherwise the form would be submitted twice and an AlreadySubmittedException is thrown.
have you actually tried to use the fix for your issue? it cannot work in its current form AFAIK.
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.
It shouldn't throw the AlreadySubmittedException, because it follows a different execution path inside submit()
1 Form::submit(Request)
1.1 Form::handleRequest(Request)
1.1.1 HttpFoundationRequestHandler::handleRequest(Form, Request)
1.1.1.1 Form::submit(data)
only at: 1.1.1.1 Form::submitted = true
And if we used bind
preBindEvent dispatches (does not submit, so submitted is still false)
bind will call Form::submit(Request) which will follow the same execution path above.
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.
ah there is a return
in front of handleRequest. I didn't see that and this is what I thought is missing.
@Tobion Does it get a +1 from you? |
Hm I see one problem. When using So I think the only non-breaking solution is to fix the https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Form/Extension/HttpFoundation/EventListener/BindRequestListener.php according to https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Form/Extension/HttpFoundation/HttpFoundationRequestHandler.php. |
But then again, this approach is deprecated anyway. So I'm not sure it's really worth to do it. |
When the argument of Form::submit is a Request object it forwards to Form::HandleRequest.
Fixes the issue with uploaded files exceeding post_max_size,
and form marked as valid with empty fields.