From: Lukas Reschke Date: Fri, 27 Feb 2015 19:04:52 +0000 (+0100) Subject: Add detection for invalid CLI configuration for settings page X-Git-Tag: v8.1.0alpha1~370^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b6d8a48ce1cefdd11db90d7a4b359f22b2906962;p=nextcloud-server.git Add detection for invalid CLI configuration for settings page This change will log all failures that prevent the CLI cronjob from happening to the database and display a warning to administrators when an error happened. To test: 1. Configure some invalid CLI php.ini settings 2. Enable the CLI cronjob and run php cron.php 3. See the errors printed and also in the admin page 4. Configure the CLI settings correctly 5. Errors should be gone. Fixes https://github.com/owncloud/core/issues/13994 --- diff --git a/lib/base.php b/lib/base.php index a97b1b3dade..fb93b331d12 100644 --- a/lib/base.php +++ b/lib/base.php @@ -575,15 +575,30 @@ class OC { $errors = OC_Util::checkServer(\OC::$server->getConfig()); if (count($errors) > 0) { if (self::$CLI) { + // Convert l10n string into regular string for usage in database + $staticErrors = []; + $i = 0; foreach ($errors as $error) { echo $error['error'] . "\n"; echo $error['hint'] . "\n\n"; + $staticErrors[$i]['error'] = (string) $error['error']; + $staticErrors[$i]['hint'] = (string) $error['hint']; + $i++; } + + try { + \OC::$server->getConfig()->setAppValue('core', 'cronErrors', json_encode($staticErrors)); + } catch(\Exception $e) { + echo('Writing to database failed'); + } + exit(); } else { OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE); OC_Template::printGuestPage('', 'error', array('errors' => $errors)); + exit; } - exit; + } elseif(self::$CLI && \OC::$server->getConfig()->getSystemValue('installed', false)) { + \OC::$server->getConfig()->deleteAppValue('core', 'cronErrors'); } //try to set the session lifetime diff --git a/settings/admin.php b/settings/admin.php index 7c7ca4cada7..95940db7282 100644 --- a/settings/admin.php +++ b/settings/admin.php @@ -80,6 +80,7 @@ $template->assign('allowMailNotification', $appConfig->getValue('core', 'shareap $template->assign('onlyShareWithGroupMembers', \OC\Share\Share::shareWithGroupMembersOnly()); $databaseOverload = (strpos(\OCP\Config::getSystemValue('dbtype'), 'sqlite') !== false); $template->assign('databaseOverload', $databaseOverload); +$template->assign('cronErrors', $appConfig->getValue('core', 'cronErrors')); // warn if Windows is used $template->assign('WindowsWarning', OC_Util::runningOnWindows()); diff --git a/settings/templates/admin.php b/settings/templates/admin.php index a82d5ee8545..abb33bbca11 100644 --- a/settings/templates/admin.php +++ b/settings/templates/admin.php @@ -212,7 +212,29 @@ if ($_['suggestedOverwriteCliUrl']) { +
+

t('Cronjob encountered misconfiguration'));?>

+ + + t('It was not possible to execute the cronjob via CLI. The following technical errors have appeared:')); ?> +
+
    + error)) {?> +
  1. error) ?>
  2. +
    • hint) ?>
    + + +
+
+ +
+ +

t('Configuration Checks'));?>