diff options
author | Joas Schilling <coding@schilljs.com> | 2019-09-16 20:38:13 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2019-09-16 20:38:13 +0300 |
commit | e53d5b2dbe69850cb7508dfa43b9f4c03450da12 (patch) | |
tree | 83f3b7992d32e2d2316b3a72a1fd7b4c3573c0de /lib/base.php | |
parent | 7149ed74c1f7aaa022d349f892c4727b614b8ec6 (diff) |
Print plain error when the error page errors too
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/base.php')
-rw-r--r-- | lib/base.php | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/lib/base.php b/lib/base.php index 7812922c168..f7153247393 100644 --- a/lib/base.php +++ b/lib/base.php @@ -652,30 +652,35 @@ class OC { if (!defined('OC_CONSOLE')) { $errors = OC_Util::checkServer(\OC::$server->getSystemConfig()); if (count($errors) > 0) { - if (self::$CLI) { - // Convert l10n string into regular string for usage in database - $staticErrors = []; - foreach ($errors as $error) { - echo $error['error'] . "\n"; - echo $error['hint'] . "\n\n"; - $staticErrors[] = [ - 'error' => (string)$error['error'], - 'hint' => (string)$error['hint'], - ]; - } - + if (!self::$CLI) { + http_response_code(503); + OC_Util::addStyle('guest'); try { - \OC::$server->getConfig()->setAppValue('core', 'cronErrors', json_encode($staticErrors)); + OC_Template::printGuestPage('', 'error', array('errors' => $errors)); + exit; } catch (\Exception $e) { - echo('Writing to database failed'); + // In case any error happens when showing the error page, we simply fall back to posting the text. + // This might be the case when e.g. the data directory is broken and we can not load/write SCSS to/from it. } - exit(1); - } else { - http_response_code(503); - OC_Util::addStyle('guest'); - OC_Template::printGuestPage('', 'error', array('errors' => $errors)); - exit; } + + // Convert l10n string into regular string for usage in database + $staticErrors = []; + foreach ($errors as $error) { + echo $error['error'] . "\n"; + echo $error['hint'] . "\n\n"; + $staticErrors[] = [ + 'error' => (string)$error['error'], + 'hint' => (string)$error['hint'], + ]; + } + + try { + \OC::$server->getConfig()->setAppValue('core', 'cronErrors', json_encode($staticErrors)); + } catch (\Exception $e) { + echo('Writing to database failed'); + } + exit(1); } elseif (self::$CLI && \OC::$server->getConfig()->getSystemValue('installed', false)) { \OC::$server->getConfig()->deleteAppValue('core', 'cronErrors'); } |