Merge pull request #7073 from nextcloud/no-whitepage-of-death

Show proper error page even if the config.php has syntax errors
This commit is contained in:
Roeland Jago Douma 2017-11-07 16:28:06 +01:00 committed by GitHub
commit 469db9fbb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 1 deletions

View File

@ -70,7 +70,29 @@ try {
OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR); OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
OC_Template::printExceptionErrorPage($ex); OC_Template::printExceptionErrorPage($ex);
} catch (Error $ex) { } catch (Error $ex) {
try {
\OC::$server->getLogger()->logException($ex, array('app' => 'index')); \OC::$server->getLogger()->logException($ex, array('app' => 'index'));
} catch (Error $e) {
$claimedProtocol = strtoupper($_SERVER['SERVER_PROTOCOL']);
$validProtocols = [
'HTTP/1.0',
'HTTP/1.1',
'HTTP/2',
];
$protocol = 'HTTP/1.1';
if(in_array($claimedProtocol, $validProtocols, true)) {
$protocol = $claimedProtocol;
}
header($protocol . ' 500 Internal Server Error');
header('Content-Type: text/plain; charset=utf-8');
print("Internal Server Error\n\n");
print("The server encountered an internal error and was unable to complete your request.\n");
print("Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.\n");
print("More details can be found in the webserver log.\n");
throw $e;
}
OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR); OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
OC_Template::printExceptionErrorPage($ex); OC_Template::printExceptionErrorPage($ex);
} }