summaryrefslogtreecommitdiff
path: root/classes/rssutils.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2020-09-30 17:03:16 +0300
committerAndrew Dolgov <[email protected]>2020-09-30 17:03:16 +0300
commit8a02a728c8726f65efb78a1f07911b8e4065b4ef (patch)
tree3fc7bc9a673f679b04405b7db98cfa5f8f23ec91 /classes/rssutils.php
parente641547d37ce39ae67a119202795c51781f35228 (diff)
add DAEMON_UNSUCCESSFUL_DAYS_LIMIT tunable (defaults to 30 days)
Diffstat (limited to 'classes/rssutils.php')
-rwxr-xr-xclasses/rssutils.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/classes/rssutils.php b/classes/rssutils.php
index 0e0ea75bb..2ec24d9be 100755
--- a/classes/rssutils.php
+++ b/classes/rssutils.php
@@ -1582,6 +1582,43 @@ class RSSUtils {
$pdo->query("DELETE FROM ttrss_cat_counters_cache");
}
+ static function disable_failed_feeds() {
+ if (defined('DAEMON_UNSUCCESSFUL_DAYS_LIMIT') && DAEMON_UNSUCCESSFUL_DAYS_LIMIT > 0) {
+
+ $pdo = Db::pdo();
+
+ $pdo->beginTransaction();
+
+ $days = (int) DAEMON_UNSUCCESSFUL_DAYS_LIMIT;
+
+ if (DB_TYPE == "pgsql") {
+ $interval_query = "last_successful_update < NOW() - INTERVAL '$days days'";
+ } else if (DB_TYPE == "mysql") {
+ $interval_query = "last_successful_update < DATE_SUB(NOW(), INTERVAL $days DAY)";
+ }
+
+ $sth = $pdo->prepare("SELECT id, title, owner_uid
+ FROM ttrss_feeds
+ WHERE update_interval != -1 AND last_successful_update IS NOT NULL AND $interval_query");
+
+ $sth->execute();
+
+ while ($row = $sth->fetch()) {
+ Logger::get()->log(E_USER_NOTICE,
+ sprintf("Auto disabling feed %d (%s, UID: %d) because it failed to update for %d days.",
+ $row["id"], clean($row["title"]), $row["owner_uid"], DAEMON_UNSUCCESSFUL_DAYS_LIMIT));
+
+ Debug::log(sprintf("Auto-disabling feed %d (failed to update for %d days).", $row["id"], DAEMON_UNSUCCESSFUL_DAYS_LIMIT));
+ }
+
+ $sth = $pdo->prepare("UPDATE ttrss_feeds SET update_interval = -1 WHERE
+ update_interval != -1 AND last_successful_update IS NOT NULL AND $interval_query");
+ $sth->execute();
+
+ $pdo->commit();
+ }
+ }
+
static function housekeeping_user($owner_uid) {
$tmph = new PluginHost();
@@ -1598,6 +1635,7 @@ class RSSUtils {
self::expire_feed_archive();
self::cleanup_feed_browser();
self::cleanup_feed_icons();
+ self::disable_failed_feeds();
Article::purge_orphans();
self::cleanup_counters_cache();