Problem/Motivation
When using Drupal on versions of PHP before 5.6, along with code that utilize PSR-7 HTTP messages, calling \Symfony\Component\HttpFoundation\Request::getContent()
can result in a LogicException being thrown, with the message:
getContent() can only be called once when using the resource return type and PHP below 5.6.
This only occurs if libraries or modules that use PSR-7 messages are executed before the call to Request::getContent()
. I've tracked this to an issue in the DiactorosFactory::createRequest()
in v0.2 of the symfony/psr-http-message-bridge
library. This method calls Request::getContent(true)
, which causes the LogicException on any later calls of Request::getContent()
. Version 1.0.0 of that library fixes this issue.
Steps to reproduce:
1) Install jsonapi and simple_oauth modules
2) Configure simple_oauth and acquire an OAuth2 token via password grant as per the instructions at https://www.drupal.org/project/simple_oauth
3) Make a JSON API request using that access token. This will result in a 500 HTTP response, due to the LogicException.
Proposed resolution
Update Drupal core's composer.json
to require version 1.0.0 of symfony/psr-http-message-bridge
Remaining tasks
User interface changes
None
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#2 | getcontent_can_only.patch | 2.45 KB | hampercm |
Comments
Comment #2
hampercm CreditAttribution: hampercm as a volunteer and at Acquia commentedComment #3
hampercm CreditAttribution: hampercm as a volunteer and at Acquia commentedComment #4
wturrell CreditAttribution: wturrell as a volunteer commentedI'd be happy to test this, however it looks like instructions on the simple_oauth project page are out of date, should you feel like updating the Steps to Reproduce.
e.g.:
- URLs are now mostly "access_token" rather than "simple_oauth"
- I can't find anywhere to specify the path of the private/public keypair I'm required to create
Comment #5
hampercm CreditAttribution: hampercm at Acquia commented@wturrell Those instructions should still be good. Make sure you're using the 2.x branch of the simple_oauth module. Note that you can skip any steps that mention REST or RESTUI as the steps-to-reproduce use JSON API instead.
Comment #6
Anonymous (not verified) CreditAttribution: Anonymous commentedThanks! Now
"symfony/psr-http-message-bridge": "^1.0",
. What status of issue will be correct?Comment #7
Anonymous (not verified) CreditAttribution: Anonymous commentedProposed resolution done in #2862254: Update non-Symfony dependencies before 8.3.0. So, looks like this issue Fixed.
Comment #8
tstoecklerYup. Fixing issue status.