diff options
Diffstat (limited to 'classes/rssutils.php')
-rwxr-xr-x | classes/rssutils.php | 70 |
1 files changed, 21 insertions, 49 deletions
diff --git a/classes/rssutils.php b/classes/rssutils.php index 6048c8310..82a6963e8 100755 --- a/classes/rssutils.php +++ b/classes/rssutils.php @@ -19,51 +19,9 @@ class RSSUtils { return preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $str); } - static function update_feedbrowser_cache() { - + static function cleanup_feed_browser() { $pdo = Db::pdo(); - - $sth = $pdo->query("SELECT feed_url, site_url, title, COUNT(id) AS subscribers - FROM ttrss_feeds WHERE feed_url NOT IN (SELECT feed_url FROM ttrss_feeds - WHERE private IS true OR auth_login != '' OR auth_pass != '' OR feed_url LIKE '%:%@%/%') - GROUP BY feed_url, site_url, title ORDER BY subscribers DESC LIMIT 1000"); - - $pdo->beginTransaction(); - $pdo->query("DELETE FROM ttrss_feedbrowser_cache"); - - $count = 0; - - while ($line = $sth->fetch()) { - - $subscribers = $line["subscribers"]; - $feed_url = $line["feed_url"]; - $title = $line["title"]; - $site_url = $line["site_url"]; - - $tmph = $pdo->prepare("SELECT subscribers FROM - ttrss_feedbrowser_cache WHERE feed_url = ?"); - $tmph->execute([$feed_url]); - - if (!$tmph->fetch()) { - - $tmph = $pdo->prepare("INSERT INTO ttrss_feedbrowser_cache - (feed_url, site_url, title, subscribers) - VALUES - (?, ?, ?, ?)"); - - $tmph->execute([$feed_url, $site_url, $title, $subscribers]); - - ++$count; - - } - - } - - $pdo->commit(); - - return $count; - } static function update_daemon_common($limit = DAEMON_FEED_LIMIT) { @@ -305,7 +263,7 @@ class RSSUtils { $pdo = Db::pdo(); - $sth = $pdo->prepare("SELECT title FROM ttrss_feeds WHERE id = ?"); + $sth = $pdo->prepare("SELECT title, site_url FROM ttrss_feeds WHERE id = ?"); $sth->execute([$feed]); if (!$row = $sth->fetch()) { @@ -315,11 +273,12 @@ class RSSUtils { } $title = $row["title"]; + $site_url = $row["site_url"]; // feed was batch-subscribed or something, we need to get basic info // this is not optimal currently as it fetches stuff separately TODO: optimize - if ($title == "[Unknown]") { - Debug::log("setting basic feed info for $feed..."); + if ($title == "[Unknown]" || !$title || !$site_url) { + Debug::log("setting basic feed info for $feed [$title, $site_url]..."); RSSUtils::set_basic_feed_info($feed); } @@ -1288,6 +1247,20 @@ class RSSUtils { } } + static function expire_feed_archive() { + Debug::log("Removing old archived feeds..."); + + $pdo = Db::pdo(); + + if (DB_TYPE == "pgsql") { + $pdo->query("DELETE FROM ttrss_archived_feeds + WHERE created < NOW() - INTERVAL '1 month'"); + } else { + $pdo->query("DELETE FROM ttrss_archived_feeds + WHERE created < DATE_SUB(NOW(), INTERVAL 1 MONTH)"); + } + } + static function expire_lock_files() { Debug::log("Removing old lock files...", Debug::$LOG_VERBOSE); @@ -1526,9 +1499,8 @@ class RSSUtils { RSSUtils::expire_cached_files(); RSSUtils::expire_lock_files(); RSSUtils::expire_error_log(); - - $count = RSSUtils::update_feedbrowser_cache(); - Debug::log("Feedbrowser updated, $count feeds processed."); + RSSUtils::expire_feed_archive(); + RSSUtils::cleanup_feed_browser(); Article::purge_orphans(); RSSUtils::cleanup_counters_cache(); |