Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[HttpFoundation] fixed Request::getContent() reusage bug #19549

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
wants to merge 3 commits into from
Closed

[HttpFoundation] fixed Request::getContent() reusage bug #19549

wants to merge 3 commits into from

Conversation

1ma
Copy link
Contributor

@1ma 1ma commented Aug 5, 2016

Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

After calling Request::getContent(true), subsequent calls to the
same instance method (withouth the $asResource flag) always returned
false instead of the request body as a plain string.

A unit test already existed to guard against this behaviour (the 'Resource then fetch' case) but it
yielded a false positive because it was comparing '' to false using
PHPUnit's assertEquals method instead of assertSame.

For completeness sake I also added the missing usage permutations in
the data provider, which already worked OK.

After calling Request::getContent(true), subsequent calls to the
same instance method (withouth the $asResource flag) always returned
false instead of the request body as a plain string.
A unit test already existed to guard against this behaviour but it
yielded a false positive because it was comparing '' to false using
PHPUnit's assertEquals() instead of assertSame().
For completeness sake I also added the missing usage permutations in
the test data provider.
@1ma 1ma changed the title [HttpFoundation] fixed testGetContentCanBeCalledTwiceWithResources scenario [HttpFoundation] fixed Request::getContent() reusage bug Aug 5, 2016
@fabpot
Copy link
Member

fabpot commented Aug 15, 2016

Thank you @1ma.

fabpot added a commit that referenced this pull request Aug 15, 2016
…1ma)

This PR was squashed before being merged into the 2.7 branch (closes #19549).

Discussion
----------

[HttpFoundation] fixed Request::getContent() reusage bug

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

After calling ```Request::getContent(true)```, subsequent calls to the
same instance method (withouth the ```$asResource``` flag) always returned
```false``` instead of the request body as a plain string.

A unit test already existed to guard against this behaviour (the 'Resource then fetch' case) but it
yielded a false positive because it was comparing ```''``` to ```false``` using
PHPUnit's ```assertEquals``` method instead of ```assertSame```.

For completeness sake I also added the missing usage permutations in
the data provider, which already worked OK.

Commits
-------

c42ac66 [HttpFoundation] fixed Request::getContent() reusage bug
@fabpot fabpot closed this Aug 15, 2016
@1ma 1ma deleted the getcontent-fix branch August 16, 2016 15:29
This was referenced Sep 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.