summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2016-04-13 21:09:18 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2016-04-13 21:09:18 +0200
commitdb10a37080730d3a1957b858f8bdc1710801bcbe (patch)
treebe622672fa5bee033b59594dc33060fac7f71b55
parent87cd4f362396d754632bad842daedac4d8741307 (diff)
Better cron warning message, do not run feed updates when in ajax or web cron mode
-rw-r--r--CHANGELOG.md4
-rw-r--r--README.md11
-rw-r--r--cron/updater.php7
-rw-r--r--js/directive/NewsInstantNotification.js10
-rw-r--r--service/statusservice.php22
-rw-r--r--templates/part.content.cronwarning.php33
6 files changed, 51 insertions, 36 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9529a262e..0f725bd2c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+owncloud-news (8.5.0)
+* **Bugfix**: Do not run feed updates when ajax or web cron mode was detected because it can lead to very long load times, timeouts, data corruption and database inconsistencies
+* **Bugfix**: Fix multiple error messages and outdated links for cron error messages
+
owncloud-news (8.4.1)
* **Bugfix**: Fix error messages in the logs which were caused by outdated template includes, #972
diff --git a/README.md b/README.md
index c4e2f9312..0121f4a79 100644
--- a/README.md
+++ b/README.md
@@ -258,14 +258,23 @@ Check the **owncloud/data/owncloud.log** for hints why it failed. After the issu
"maintenance" => false,
### Feeds are not updated
+Feeds can be updated using ownCloud's system cron or any program that implements the [News app's updater API](https://github.com/owncloud/news/wiki/Updater-1.2), most notably [ownCloud News Updater](https://github.com/owncloud/news-updater):
+
+System Cron:
* Check if the config.ini in **owncloud/data/news/config/config.ini** contains **useCronUpdates = true**
+* Check if you are using the system cron (Cron) setting on the admin page. AJAX and Web cron will not update feeds
* Check if the cronjob exists with **crontab -u www-data -e** (replace www-data with your httpd user)
* Check the file permissions of the **cron.php** file and if **www-data** (or whatever your httpd user is called like) can read and execute that script
* Check if you can execute the cron with **sudo -u www-data php -f owncloud/cron.php** (replace www-data with your httpd user)
* Check if the cronjob is ever executed by placing an **error_log('updating');** in the [background job file](https://github.com/owncloud/news/blob/master/cron/updater.php#L28). If the cronjob runs, there should be an updating log statement in your httpd log.
* If there is no **updating** statement in your logs check if your cronjob is executed by executing a different script
* If your cron works fine but owncloud's cronjobs are never executed, file a bug in [core](https://github.com/owncloud/core/)
-* Try the [updater script](https://github.com/owncloud/news-updater)
+
+[ownCloud News Updater](https://github.com/owncloud/news-updater):
+* Check if the config.ini in **owncloud/data/news/config/config.ini** contains **useCronUpdates = false**
+* Start the updater in loglevel info mode, e.g.:
+
+ owncloud_news_updater --loglevel info -c /path/to/config.ini
### Adding feeds that use self-signed certificates
If you want to add a feed that uses a self-signed certificate that is not signed by a trusted CA the request will fail with "SSL certficate is invalid". A common solution is to turn off the certificate verification **which is wrong** and **makes your installation vulnerable to MITM attacks**. Therefore **turning off certificate verification is not supported**.
diff --git a/cron/updater.php b/cron/updater.php
index 84aadc8f0..d2c5aaa96 100644
--- a/cron/updater.php
+++ b/cron/updater.php
@@ -16,7 +16,8 @@ namespace OCA\News\Cron;
use OCA\News\AppInfo\Application;
use OCA\News\Config\Config;
-use \OCA\News\Utility\Updater as UpdaterService;
+use OCA\News\Service\StatusService;
+use OCA\News\Utility\Updater as UpdaterService;
class Updater {
@@ -28,7 +29,9 @@ class Updater {
// make it possible to turn off cron updates if you use an external
// script to execute updates in parallel
- if ($container->query(Config::class)->getUseCronUpdates()) {
+ $useCronUpdates = $container->query(Config::class)->getUseCronUpdates();
+ $isProperlyConfigured = $container->query(StatusService::class)->isProperlyConfigured();
+ if ($useCronUpdates && $isProperlyConfigured) {
$container->query(UpdaterService::class)->update();
$container->query(UpdaterService::class)->beforeUpdate();
$container->query(UpdaterService::class)->afterUpdate();
diff --git a/js/directive/NewsInstantNotification.js b/js/directive/NewsInstantNotification.js
index f66db3d69..893da8f7c 100644
--- a/js/directive/NewsInstantNotification.js
+++ b/js/directive/NewsInstantNotification.js
@@ -10,14 +10,16 @@
app.directive('newsInstantNotification', function () {
'use strict';
-
+ var shown = false;
return {
restrict: 'E',
link: function (scope, elem) {
elem.hide();
-
- var notification = elem.html();
- OC.Notification.showHtml(notification);
+ if (!shown) {
+ shown = true;
+ var notification = elem.html();
+ OC.Notification.showHtml(notification);
+ }
}
};
diff --git a/service/statusservice.php b/service/statusservice.php
index 2273d5a98..b36e64c1b 100644
--- a/service/statusservice.php
+++ b/service/statusservice.php
@@ -30,28 +30,26 @@ class StatusService {
$this->appName = $AppName;
}
-
- public function getStatus() {
- $improperlyConfiguredCron = false;
-
- $version = $this->settings->getAppValue(
- $this->appName, 'installed_version'
- );
+ public function isProperlyConfigured() {
$cronMode = $this->settings->getAppValue(
'core', 'backgroundjobs_mode'
);
- $cronOn = $this->config->getUseCronUpdates();
+ $cronOff = !$this->config->getUseCronUpdates();
// check for cron modes which may lead to problems
- if ($cronMode !== 'cron' && $cronOn) {
- $improperlyConfiguredCron = true;
- }
+ return $cronMode === 'cron' || $cronOff;
+ }
+
+ public function getStatus() {
+ $version = $this->settings->getAppValue(
+ $this->appName, 'installed_version'
+ );
return [
'version' => $version,
'warnings' => [
- 'improperlyConfiguredCron' => $improperlyConfiguredCron
+ 'improperlyConfiguredCron' => !$this->isProperlyConfigured()
]
];
}
diff --git a/templates/part.content.cronwarning.php b/templates/part.content.cronwarning.php
index ca3371ddb..3adfee2b7 100644
--- a/templates/part.content.cronwarning.php
+++ b/templates/part.content.cronwarning.php
@@ -1,24 +1,23 @@
<?php if ($_['cronWarning']) { ?>
<news-instant-notification id="cron-warning">
<p><?php p($l->t('Ajax or Web cron mode detected! Your feeds will not be updated!')); ?></p>
- <ul>
- <li>
- <a href="https://doc.owncloud.org/server/9.0/admin_manual/configuration_server/background_jobs_configuration.html#cron"
- target="_blank">
+ <ul>
+ <li>
+ <a href="https://doc.owncloud.org/server/9.0/admin_manual/configuration_server/background_jobs_configuration.html#cron"
+ target="_blank">
<?php
- p($l->t('How to set up the operating system cron'));
+ p($l->t('How to set up the operating system cron'));
?>
- </a>
- </li>
- <li>
- <a href="https://github.com/owncloud/news-updater"
- target="_blank">
- <?php
- p($l->t('Install and set up a faster parallel updater that uses the News app\'s update API'));
- ?>
- </a>
- </li>
- </ul>
- </p>
+ </a>
+ </li>
+ <li>
+ <a href="https://github.com/owncloud/news-updater"
+ target="_blank">
+ <?php
+ p($l->t('Install and set up a faster parallel updater that uses the News app\'s update API'));
+ ?>
+ </a>
+ </li>
+ </ul>
</news-instant-notification>
<?php }; ?>