From 478b95cc20de9173cbda4c7f69ac3a78ca448250 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Fri, 29 Jun 2018 11:22:05 +0200 Subject: [PATCH] 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 --- index.php | 8 ++++++-- lib/private/legacy/template.php | 18 +++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/index.php b/index.php index 4b5991a3ade..ba83054ccca 100644 --- a/index.php +++ b/index.php @@ -50,8 +50,12 @@ try { try { OC_Template::printErrorPage($ex->getMessage(), $ex->getHint(), 503); } 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 OC_Template::printExceptionErrorPage($ex, 500); diff --git a/lib/private/legacy/template.php b/lib/private/legacy/template.php index f84d6386deb..1505089d561 100644 --- a/lib/private/legacy/template.php +++ b/lib/private/legacy/template.php @@ -358,9 +358,21 @@ class OC_Template extends \OC\Template\Base { $content->assign('requestID', $request->getId()); $content->printPage(); } 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'); print("Internal Server Error\n\n");