summaryrefslogtreecommitdiffstats
path: root/lib/base.php
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-02-27 20:04:52 +0100
committerLukas Reschke <lukas@owncloud.com>2015-02-27 20:20:34 +0100
commitb6d8a48ce1cefdd11db90d7a4b359f22b2906962 (patch)
tree97d515ceca808a54c932fc9d873488931ede4fc7 /lib/base.php
parent13b0b7dfaf6553411928677420d8d21fa352bb3e (diff)
downloadnextcloud-server-b6d8a48ce1cefdd11db90d7a4b359f22b2906962.tar.gz
nextcloud-server-b6d8a48ce1cefdd11db90d7a4b359f22b2906962.zip
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
Diffstat (limited to 'lib/base.php')
-rw-r--r--lib/base.php17
1 files changed, 16 insertions, 1 deletions
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