mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-16 09:34:39 +00:00
api, race condition in setting json body on dynamic class
This commit is contained in:
parent
8d3797a2ac
commit
1a16bfba0c
@ -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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user