Skip to content
Browse files

Fix incorrect handling of request data.

Request data that is invalid should not be parsed into null. Instead it
should always be cast as an array. This prevents other parts of the
framework from failing. For example patchEntity() will emit errors when
passed non-array data.
  • Loading branch information...
markstory committed May 7, 2015
1 parent 522ed2f commit b896127099089c1394c3df66d5112281aefa554e
@@ -240,8 +240,8 @@ public function startup(Event $event)
foreach ($this->_inputTypeMap as $type => $handler) {
if ($this->requestedWith($type)) {
$input = call_user_func_array([$controller->request, 'input'], $handler);
$request->data = $input;
$input = call_user_func_array([$request, 'input'], $handler);
$request->data = (array)$input;
@@ -473,6 +473,39 @@ public function testStartupCallbackCharset()
* Test that processing data results in an array.
* @return void
* @triggers Controller.startup $this->Controller
public function testStartupProcessData()
$this->Controller->request = $this->getMock('Cake\Network\Request', ['_readInput']);
$this->Controller->request->env('REQUEST_METHOD', 'POST');
$this->Controller->request->env('CONTENT_TYPE', 'application/json');
$event = new Event('Controller.startup', $this->Controller);
$this->assertEquals([], $this->Controller->request->data);
$this->assertEquals(['invalid'], $this->Controller->request->data);
$this->assertEquals(['valid' => true], $this->Controller->request->data);
* Test mapping a new type and having startup process it.

0 comments on commit b896127

Please sign in to comment.
You can’t perform that action at this time.