浏览代码

Try to not run into the white page of death and still log something in the web server error log

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
tags/v14.0.0beta1
Morris Jobke 6 年前
父节点
当前提交
478b95cc20
没有帐户链接到提交者的电子邮件
共有 2 个文件被更改,包括 21 次插入5 次删除
  1. 6
    2
      index.php
  2. 15
    3
      lib/private/legacy/template.php

+ 6
- 2
index.php 查看文件

try { try {
OC_Template::printErrorPage($ex->getMessage(), $ex->getHint(), 503); OC_Template::printErrorPage($ex->getMessage(), $ex->getHint(), 503);
} catch (Exception $ex2) { } catch (Exception $ex2) {
\OC::$server->getLogger()->logException($ex, array('app' => 'index'));
\OC::$server->getLogger()->logException($ex2, array('app' => 'index'));
try {
\OC::$server->getLogger()->logException($ex, array('app' => 'index'));
\OC::$server->getLogger()->logException($ex2, array('app' => 'index'));
} catch (Throwable $e) {
// no way to log it properly - but to avoid a white page of death we try harder and ignore this one here
}


//show the user a detailed error page //show the user a detailed error page
OC_Template::printExceptionErrorPage($ex, 500); OC_Template::printExceptionErrorPage($ex, 500);

+ 15
- 3
lib/private/legacy/template.php 查看文件

$content->assign('requestID', $request->getId()); $content->assign('requestID', $request->getId());
$content->printPage(); $content->printPage();
} catch (\Exception $e) { } catch (\Exception $e) {
$logger = \OC::$server->getLogger();
$logger->logException($exception, ['app' => 'core']);
$logger->logException($e, ['app' => 'core']);
try {
$logger = \OC::$server->getLogger();
$logger->logException($exception, ['app' => 'core']);
$logger->logException($e, ['app' => 'core']);
} catch (Throwable $e) {
// no way to log it properly - but to avoid a white page of death we send some output
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 server log.\n");

// and then throw it again to log it at least to the web server error log
throw $e;
}


header('Content-Type: text/plain; charset=utf-8'); header('Content-Type: text/plain; charset=utf-8');
print("Internal Server Error\n\n"); print("Internal Server Error\n\n");

正在加载...
取消
保存