Disable automatically a feed after too many failures

This commit is contained in:
Frederic Guillot 2016-12-27 22:20:25 -05:00
parent 0b45f1b863
commit 2a9fd5fb62
8 changed files with 14 additions and 4 deletions

View File

@ -12,6 +12,7 @@ Version 1.2.0 (unreleased)
* Always update feed URL to avoid useless redirections for futures requests * Always update feed URL to avoid useless redirections for futures requests
* Add support for Wallabag service * Add support for Wallabag service
* Show last parsing error message in user interface * Show last parsing error message in user interface
* Disable automatically a feed after too many failures
* Add unit tests * Add unit tests
Migration procedure from 1.1.x to 1.2.0: Migration procedure from 1.1.x to 1.2.0:

View File

@ -33,6 +33,7 @@ defined('PROXY_USERNAME') or define('PROXY_USERNAME', '');
defined('PROXY_PASSWORD') or define('PROXY_PASSWORD', ''); defined('PROXY_PASSWORD') or define('PROXY_PASSWORD', '');
defined('SUBSCRIPTION_CONCURRENT_REQUESTS') or define('SUBSCRIPTION_CONCURRENT_REQUESTS', 5); defined('SUBSCRIPTION_CONCURRENT_REQUESTS') or define('SUBSCRIPTION_CONCURRENT_REQUESTS', 5);
defined('SUBSCRIPTION_DISABLE_THRESHOLD_ERROR') or define('SUBSCRIPTION_DISABLE_THRESHOLD_ERROR', 10);
defined('RULES_DIRECTORY') or define('RULES_DIRECTORY', ROOT_DIRECTORY.DIRECTORY_SEPARATOR.'rules'); defined('RULES_DIRECTORY') or define('RULES_DIRECTORY', ROOT_DIRECTORY.DIRECTORY_SEPARATOR.'rules');

View File

@ -104,10 +104,12 @@ function update_feed($user_id, $feed_id)
); );
if (! empty($error_message)) { if (! empty($error_message)) {
$error_count = $subscription['parsing_error'] + 1;
Model\Feed\update_feed($user_id, $feed_id, array( Model\Feed\update_feed($user_id, $feed_id, array(
'last_checked' => time(), 'last_checked' => time(),
'parsing_error' => 1, 'parsing_error' => $error_count,
'parsing_error_message' => $error_message, 'parsing_error_message' => $error_message,
'enabled' => $error_count > SUBSCRIPTION_DISABLE_THRESHOLD_ERROR ? 0 : 1,
)); ));
return false; return false;

View File

@ -47,7 +47,7 @@ function version_1(PDO $pdo)
etag VARCHAR(255), etag VARCHAR(255),
enabled BOOLEAN DEFAULT TRUE, enabled BOOLEAN DEFAULT TRUE,
download_content BOOLEAN DEFAULT FALSE, download_content BOOLEAN DEFAULT FALSE,
parsing_error BOOLEAN DEFAULT FALSE, parsing_error INTEGER DEFAULT 0,
rtl BOOLEAN DEFAULT FALSE, rtl BOOLEAN DEFAULT FALSE,
cloak_referrer BOOLEAN DEFAULT FALSE, cloak_referrer BOOLEAN DEFAULT FALSE,
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,

View File

@ -22,7 +22,7 @@
</ul> </ul>
</div> </div>
<?php if ($feed['parsing_error']): ?> <?php if ($feed['parsing_error'] > 0): ?>
<p class="alert alert-error"> <p class="alert alert-error">
<?php echo t('An error occurred during the last check: "%s".', $feed['parsing_error_message']) ?> <?php echo t('An error occurred during the last check: "%s".', $feed['parsing_error_message']) ?>
</p> </p>

View File

@ -23,7 +23,7 @@
<section class="items"> <section class="items">
<?php foreach ($feeds as $feed): ?> <?php foreach ($feeds as $feed): ?>
<article data-feed-id="<?php echo $feed['id'] ?>" <?php echo (! $feed['enabled']) ? 'data-feed-disabled="1"' : '' ?> <?php echo ($feed['parsing_error']) ? 'data-feed-error="1"' : '' ?>> <article data-feed-id="<?php echo $feed['id'] ?>" <?php echo (! $feed['enabled']) ? 'data-feed-disabled="1"' : '' ?> <?php echo $feed['parsing_error'] > 0 ? 'data-feed-error="1"' : '' ?>>
<h2> <h2>
<?php if (! $feed['enabled']): ?> <?php if (! $feed['enabled']): ?>
<span title="<?php echo t('Subscription disabled') ?>"></span> <span title="<?php echo t('Subscription disabled') ?>"></span>

View File

@ -55,6 +55,9 @@ define('PROXY_PASSWORD', '');
// Reduce this number on systems with limited processing power // Reduce this number on systems with limited processing power
define('SUBSCRIPTION_CONCURRENT_REQUESTS', 5); define('SUBSCRIPTION_CONCURRENT_REQUESTS', 5);
// Disable automatically a feed after X parsing failure
define('SUBSCRIPTION_DISABLE_THRESHOLD_ERROR', 10);
// Allow the cronjob to be accessible from the browser // Allow the cronjob to be accessible from the browser
define('ENABLE_CRONJOB_HTTP_ACCESS', true); define('ENABLE_CRONJOB_HTTP_ACCESS', true);

View File

@ -104,6 +104,9 @@ define('PROXY_PASSWORD', '');
// Reduce this number on systems with limited processing power // Reduce this number on systems with limited processing power
define('SUBSCRIPTION_CONCURRENT_REQUESTS', 5); define('SUBSCRIPTION_CONCURRENT_REQUESTS', 5);
// Disable automatically a feed after X parsing failure
define('SUBSCRIPTION_DISABLE_THRESHOLD_ERROR', 10);
// Allow the cronjob to be accessible from the browser // Allow the cronjob to be accessible from the browser
define('ENABLE_CRONJOB_HTTP_ACCESS', true); define('ENABLE_CRONJOB_HTTP_ACCESS', true);