Fixed Grav core update potentially spinning forever because of an error which happens after a successful upgrade

This commit is contained in:
Matias Griese
2018-11-07 19:11:36 +02:00
parent 82eb4ce380
commit 3d765e8ece
3 changed files with 59 additions and 19 deletions

View File

@@ -202,6 +202,29 @@ class AdminBaseController
$this->redirectCode = $code;
}
/**
* Sends JSON response and terminates the call.
*
* @param array $response
* @param int $code
* @return bool
*/
protected function sendJsonResponse(array $response, $code = 200)
{
// Make sure nothing extra gets written to the response.
while (ob_get_level()) {
ob_end_clean();
}
// JSON response.
http_response_code($code);
header('Content-Type: application/json');
header('Cache-Control: no-cache, no-store, must-revalidate');
echo json_encode($response);
exit();
}
/**
* Handles ajax upload for files.
* Stores in a flash object the temporary file and deals with potential file errors.