Skip to content
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

[5.4] Properly set the JSON payload of FormRequests #17760

Merged
merged 1 commit into from
Feb 3, 2017
Merged

[5.4] Properly set the JSON payload of FormRequests #17760

merged 1 commit into from
Feb 3, 2017

Conversation

themsaid
Copy link
Member

@themsaid themsaid commented Feb 3, 2017

This PR highlights the cause of the issue experienced in #17753

When the transformation middleware runs, $request->json() is called and the returned parameter bag is replaced with the transformed one, later calls to ->json() presents the modified bag not the original one: https://github.com/laravel/framework/blob/5.4/src/Illuminate/Http/Request.php#L294

For form requests when we initialise it we pass the original content:

$current->cookies->all(), $files, $current->server->all(), $current->getContent()

So when ->json() is called on the form request, it'll read the original content of the request and thus why the transformation won't take effect.

In this PR I explicitly set the json bag of the form request from the json bag of the original request, this way ->json() won't have to look into the content since there's already a bag present.

@taylorotwell taylorotwell merged commit 9a1c5f3 into laravel:5.4 Feb 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants