diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index 081558597..903fa72ca 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -162,11 +162,12 @@ class CakeRequest implements ArrayAccess { protected function _processPost() { if ($_POST) { $this->data = $_POST; - } elseif ($this->is('put') || $this->is('delete')) { - $this->data = $this->_readInput(); - if (strpos(env('CONTENT_TYPE'), 'application/x-www-form-urlencoded') === 0) { - parse_str($this->data, $this->data); - } + } elseif ( + ($this->is('put') || $this->is('delete')) && + strpos(env('CONTENT_TYPE'), 'application/x-www-form-urlencoded') === 0 + ) { + $data = $this->_readInput(); + parse_str($data, $this->data); } if (ini_get('magic_quotes_gpc') === '1') { $this->data = stripslashes_deep($this->data); diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index e5ba8f850..d9ae235d4 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -311,9 +311,10 @@ class CakeRequestTest extends CakeTestCase { $request = $this->getMock('TestCakeRequest', array('_readInput')); $request->expects($this->at(0))->method('_readInput') - ->will($this->returnValue('{Article":["title"]}')); + ->will($this->returnValue('{"Article":["title"]}')); $request->reConstruct(); - $this->assertEquals('{Article":["title"]}', $request->data); + $result = $request->input('json_decode', true); + $this->assertEquals(array('title'), $result['Article']); } /**