[HttpFoundation] fixed Request::getContent() reusage bug
This commit is contained in:
parent
aae8e3da57
commit
c42ac660cb
|
@ -1516,7 +1516,7 @@ class Request
|
|||
return stream_get_contents($this->content);
|
||||
}
|
||||
|
||||
if (null === $this->content) {
|
||||
if (null === $this->content || false === $this->content) {
|
||||
$this->content = file_get_contents('php://input');
|
||||
}
|
||||
|
||||
|
|
|
@ -1042,8 +1042,16 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
|||
$req->getContent($second);
|
||||
}
|
||||
|
||||
public function getContentCantBeCalledTwiceWithResourcesProvider()
|
||||
{
|
||||
return array(
|
||||
'Resource then fetch' => array(true, false),
|
||||
'Resource then resource' => array(true, true),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getContentCantBeCalledTwiceWithResourcesProvider
|
||||
* @dataProvider getContentCanBeCalledTwiceWithResourcesProvider
|
||||
* @requires PHP 5.6
|
||||
*/
|
||||
public function testGetContentCanBeCalledTwiceWithResources($first, $second)
|
||||
|
@ -1060,12 +1068,14 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
|||
$b = stream_get_contents($b);
|
||||
}
|
||||
|
||||
$this->assertEquals($a, $b);
|
||||
$this->assertSame($a, $b);
|
||||
}
|
||||
|
||||
public function getContentCantBeCalledTwiceWithResourcesProvider()
|
||||
public function getContentCanBeCalledTwiceWithResourcesProvider()
|
||||
{
|
||||
return array(
|
||||
'Fetch then fetch' => array(false, false),
|
||||
'Fetch then resource' => array(false, true),
|
||||
'Resource then fetch' => array(true, false),
|
||||
'Resource then resource' => array(true, true),
|
||||
);
|
||||
|
|
Reference in New Issue