summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2019-09-23 10:08:58 +0200
committerGitHub <noreply@github.com>2019-09-23 10:08:58 +0200
commit48a00b88e18919232430a7f44881594da6d971da (patch)
treecb1ef1cbb073ef0065cdb8b823de04ea926823b6
parenta26c5b218c143e303bc024ca5d31612e672391ab (diff)
parentad7d13a87ceb5d20559808cad2c63c445ee4047c (diff)
downloadnextcloud-server-48a00b88e18919232430a7f44881594da6d971da.tar.gz
nextcloud-server-48a00b88e18919232430a7f44881594da6d971da.zip
Merge pull request #17163 from nextcloud/bugfix/noid/print-error-on-data-dir-error
Print error on data dir error
-rw-r--r--lib/base.php45
-rw-r--r--lib/private/legacy/template.php2
2 files changed, 26 insertions, 21 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');
}
diff --git a/lib/private/legacy/template.php b/lib/private/legacy/template.php
index 6d9bf7c99f4..26b1b360adc 100644
--- a/lib/private/legacy/template.php
+++ b/lib/private/legacy/template.php
@@ -266,7 +266,7 @@ class OC_Template extends \OC\Template\Base {
* @return bool
*/
public static function printGuestPage( $application, $name, $parameters = array() ) {
- $content = new OC_Template( $application, $name, "guest" );
+ $content = new OC_Template($application, $name, $name === 'error' ? $name : 'guest');
foreach( $parameters as $key => $value ) {
$content->assign( $key, $value );
}