mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #13539 from mvdriel/empty-post-body-for-json-will-put-null-value-in-request-data
Empty post body for json will put null value in request->data
This commit is contained in:
commit
ec8022baf5
2 changed files with 15 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue