mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
fix: getGetPost() and getPostGet() when index is null
This commit is contained in:
parent
0aab05601c
commit
b4c65a1663
@ -613,6 +613,9 @@ class IncomingRequest extends Request
|
||||
*/
|
||||
public function getPostGet($index = null, $filter = null, $flags = null)
|
||||
{
|
||||
if ($index === null) {
|
||||
return array_merge($this->getGet($index, $filter, $flags), $this->getPost($index, $filter, $flags));
|
||||
}
|
||||
// Use $_POST directly here, since filter_has_var only
|
||||
// checks the initial POST data, not anything that might
|
||||
// have been added since.
|
||||
@ -630,6 +633,9 @@ class IncomingRequest extends Request
|
||||
*/
|
||||
public function getGetPost($index = null, $filter = null, $flags = null)
|
||||
{
|
||||
if ($index === null) {
|
||||
return array_merge($this->getPost($index, $filter, $flags), $this->getGet($index, $filter, $flags));
|
||||
}
|
||||
// Use $_GET directly here, since filter_has_var only
|
||||
// checks the initial GET data, not anything that might
|
||||
// have been added since.
|
||||
|
@ -563,6 +563,26 @@ final class IncomingRequestTest extends CIUnitTestCase
|
||||
$this->assertSame($_GET, $this->request->getGetPost());
|
||||
}
|
||||
|
||||
public function testPostGetSecondStream()
|
||||
{
|
||||
$_GET['get'] = '3';
|
||||
$this->assertSame($_GET, $this->request->getPostGet());
|
||||
}
|
||||
|
||||
public function testGetPostSecondStream()
|
||||
{
|
||||
$_POST['post'] = '5';
|
||||
$this->assertSame($_POST, $this->request->getGetPost());
|
||||
}
|
||||
|
||||
public function testGetPostSecondStreams()
|
||||
{
|
||||
$_GET['get'] = '3';
|
||||
$_POST['post'] = '5';
|
||||
$this->assertSame(array_merge($_GET, $_POST), $this->request->getPostGet());
|
||||
$this->assertSame(array_merge($_POST, $_GET), $this->request->getGetPost());
|
||||
}
|
||||
|
||||
public function testWithFalseBody()
|
||||
{
|
||||
// Use `false` here to simulate file_get_contents returning a false value
|
||||
|
@ -36,6 +36,6 @@ none.
|
||||
Bugs Fixed
|
||||
**********
|
||||
|
||||
none.
|
||||
- Fixed a bug when the ``CodeIgniter\HTTP\IncomingRequest::getPostGet()`` and ``CodeIgniter\HTTP\IncomingRequest::getGetPost()`` methods didn't return values from the other stream when ``index`` was set to ``null``.
|
||||
|
||||
See the repo's `CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_ for a complete list of bugs fixed.
|
||||
|
Loading…
x
Reference in New Issue
Block a user