Commit 1a16bfba authored by Ad Schellevis's avatar Ad Schellevis

api, race condition in setting json body on dynamic class

parent 8d3797a2
......@@ -137,23 +137,23 @@ class ApiControllerBase extends ControllerRoot
$req_c = $object_info->getMethod($callMethodName)->getNumberOfRequiredParameters();
if ($req_c > count($dispatcher->getParams())) {
$dispatchError = 'action ' . $dispatcher->getActionName() .
' expects at least '. $req_c . ' parameter(s)';
} else {
// if body is send as json data, parse to $_POST first
$dispatchError = $this->parseJsonBodyData();
}
if ($dispatchError != null) {
// send error to client
$this->response->setStatusCode(400, "Bad Request");
$this->response->setContentType('application/json', 'UTF-8');
$this->response->setJsonContent(
array('message' => $dispatchError,
'status' => 400)
);
$this->response->send();
return false;
' expects at least ' . $req_c . ' parameter(s)';
}
}
// if body is send as json data, parse to $_POST first
$dispatchError = empty($dispatchError) ? $this->parseJsonBodyData() : $dispatchError;
if ($dispatchError != null) {
// send error to client
$this->response->setStatusCode(400, "Bad Request");
$this->response->setContentType('application/json', 'UTF-8');
$this->response->setJsonContent(
array('message' => $dispatchError,
'status' => 400)
);
$this->response->send();
return false;
}
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment