Skip to content

[4.2] Correctly fill the $request->request parameter bag on creation #7052

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

Merged
merged 1 commit into from
Jan 26, 2015
Merged

[4.2] Correctly fill the $request->request parameter bag on creation #7052

merged 1 commit into from
Jan 26, 2015

Conversation

hannesvdvreken
Copy link
Contributor

The Illuminate\Http\Request class extends the Symfony\Component\HttpFoundation\Request. But the SymfonyRequest does not fill the property ->request (which should hold the POST parameters), except when the Content-Type header is equal to application/x-www-form-urlencoded (see source).

IlluminateRequest parses the request body if the Content-Type header is set to application/json, but only when the getInputSource() method is called. In Laravel you can request the IlluminateRequest and pass it on, but when the IlluminateRequest is used using the SymfonyRequest interface, and they access the ->request ParameterBag, it will not be loaded with the request body data if it's json formatted.

@hannesvdvreken hannesvdvreken changed the title Correctly fill the $request->request parameter bag on creation [4.2] Correctly fill the $request->request parameter bag on creation Jan 20, 2015
@taylorotwell
Copy link
Member

Can you describe the bug?

@taylorotwell
Copy link
Member

Also a test would be nice. Thanks :)

@hannesvdvreken
Copy link
Contributor Author

The bug is described in the description. I'll add a test later today.

* @return \Illuminate\Http\Request
*/
public static function createFromBase(SymfonyRequest $request)
public static function createFromBase(SymfonyRequest $base)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not rename this variable.

@hannesvdvreken
Copy link
Contributor Author

Updated.

@taylorotwell
Copy link
Member

Can you describe how this actually effects applications? What could you not do before that this fixes?

@hannesvdvreken
Copy link
Contributor Author

In our case: we pass on the SymfonyRequest object to the OAuth2 server from The PHP League with this method. It then uses the $request object to get the request body, which should been parsed (with a parsing method defined by the Content-Type header or application/x-www-form-urlencoded) by default. The $request->request ParameterBag is used here and here. It only works for application/x-www-form-urlencoded unless we manually create the $request->request ParameterBag before we set the request with setRequest() method from the AbstractServer class.

There are several people and issues with the request to support application/json like thephpleague/oauth2-server#292.

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

Successfully merging this pull request may close these issues.

3 participants