diff --git a/lib/Cake/Controller/Component/RequestHandlerComponent.php b/lib/Cake/Controller/Component/RequestHandlerComponent.php index df6ca78d0..1915b981a 100644 --- a/lib/Cake/Controller/Component/RequestHandlerComponent.php +++ b/lib/Cake/Controller/Component/RequestHandlerComponent.php @@ -220,7 +220,7 @@ class RequestHandlerComponent extends Component { foreach ($this->_inputTypeMap as $type => $handler) { if ($this->requestedWith($type)) { - $input = call_user_func_array(array($controller->request, 'input'), $handler); + $input = (array)call_user_func_array(array($controller->request, 'input'), $handler); $controller->request->data = $input; } } diff --git a/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php b/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php index 17b50cbea..bc0e49cf2 100644 --- a/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php @@ -399,6 +399,20 @@ class RequestHandlerComponentTest extends CakeTestCase { $this->assertFalse(is_object($this->Controller->data)); } +/** + * testStartupCallbackJson method + * + * @return void + */ + public function testStartupCallbackJson() { + $_SERVER['REQUEST_METHOD'] = 'PUT'; + $_SERVER['CONTENT_TYPE'] = 'application/json'; + $this->Controller->request = $this->getMock('CakeRequest', array('_readInput')); + $this->RequestHandler->startup($this->Controller); + $this->assertTrue(is_array($this->Controller->data)); + $this->assertFalse(is_object($this->Controller->data)); + } + /** * testStartupCallback with charset. *