diff options
| author | Andrew Dolgov <fox@fakecake.org> | 2025-05-04 09:36:27 +0000 |
|---|---|---|
| committer | Andrew Dolgov <fox@fakecake.org> | 2025-05-04 09:36:27 +0000 |
| commit | bb0a136944cbb60b44d655bf8e50553119210578 (patch) | |
| tree | cf6b5464b3d3be667444316608d369a081016e6d /classes/RSSUtils.php | |
| parent | bc0da8edb699eec9fb6424bb5d8650ac48dca69d (diff) | |
| parent | 01159fa6f8c2421457297914dd42039bc12b826e (diff) | |
Merge branch 'cringe-jobs' into 'master'
Cringe jobs
See merge request tt-rss/tt-rss!124
Diffstat (limited to 'classes/RSSUtils.php')
| -rw-r--r-- | classes/RSSUtils.php | 114 |
1 files changed, 75 insertions, 39 deletions
diff --git a/classes/RSSUtils.php b/classes/RSSUtils.php index 20c4bd417..a051a7dc2 100644 --- a/classes/RSSUtils.php +++ b/classes/RSSUtils.php @@ -35,11 +35,6 @@ class RSSUtils { return sha1(implode(",", $pluginhost->get_plugin_names()) . $tmp); } - static function cleanup_feed_browser(): void { - $pdo = Db::pdo(); - $pdo->query("DELETE FROM ttrss_feedbrowser_cache"); - } - static function cleanup_feed_icons(): void { $pdo = Db::pdo(); $sth = $pdo->prepare("SELECT id FROM ttrss_feeds WHERE id = ?"); @@ -81,6 +76,8 @@ class RSSUtils { die("Schema version is wrong, please upgrade the database.\n"); } + self::init_housekeeping_tasks(); + $pdo = Db::pdo(); $feeds_in_the_future = ORM::for_table('ttrss_feeds') @@ -132,7 +129,6 @@ class RSSUtils { ))"; // Test if feed is currently being updated by another process. - // TODO: Update RPC::updaterandomfeed_real() to also use 10 minutes? $updstart_thresh_qpart = 'AND (last_update_started IS NULL OR ' . Db::past_comparison_qpart('last_update_started', '<', 10, 'minute') . ')'; @@ -288,9 +284,6 @@ class RSSUtils { self::housekeeping_user($owner_uid); } - // Send feed digests by email if needed. - Digest::send_headlines_digests(); - return $nf; } @@ -1432,15 +1425,6 @@ class RSSUtils { WHERE ' . Db::past_comparison_qpart('created_at', '<', 7, 'day')); } - /** - * @deprecated table not used - */ - static function expire_feed_archive(): void { - $pdo = Db::pdo(); - - $pdo->query("DELETE FROM ttrss_archived_feeds"); - } - static function expire_lock_files(): void { Debug::log("Removing old lock files...", Debug::LOG_VERBOSE); @@ -1659,14 +1643,6 @@ class RSSUtils { mb_strtolower(strip_tags($title), 'utf-8')); } - /* counter cache is no longer used, if called truncate leftover data */ - static function cleanup_counters_cache(): void { - $pdo = Db::pdo(); - - $pdo->query("DELETE FROM ttrss_counters_cache"); - $pdo->query("DELETE FROM ttrss_cat_counters_cache"); - } - static function disable_failed_feeds(): void { if (Config::get(Config::DAEMON_UNSUCCESSFUL_DAYS_LIMIT) > 0) { @@ -1735,20 +1711,80 @@ class RSSUtils { } } + /** Init all system tasks which are run periodically by updater in housekeeping_common() */ + static function init_housekeeping_tasks() : void { + Debug::log('Registering scheduled tasks for housekeeping...'); + + $scheduler = Scheduler::getInstance(); + + $scheduler->add_scheduled_task('purge_orphans', '@daily', + function() { + Article::_purge_orphans(); + + return 0; + } + ); + + $scheduler->add_scheduled_task('disk_cache_expire_all', '@daily', + function() { + $cache = DiskCache::instance(""); + $cache->expire_all(); + + return 0; + } + ); + + $scheduler->add_scheduled_task('disable_failed_feeds', '@daily', + function() { + self::disable_failed_feeds(); + + return 0; + } + ); + + $scheduler->add_scheduled_task('migrate_feed_icons', '@daily', + function() { + self::migrate_feed_icons(); + + return 0; + } + ); + + $scheduler->add_scheduled_task('cleanup_feed_icons', '@daily', + function() { + self::cleanup_feed_icons(); + + return 0; + } + ); + + $scheduler->add_scheduled_task('expire_error_log', '@hourly', + function() { + self::expire_error_log(); + + return 0; + } + ); + + $scheduler->add_scheduled_task('expire_lock_files', '@hourly', + function() { + self::expire_lock_files(); + + return 0; + } + ); + + $scheduler->add_scheduled_task('send_headlines_digests', '@hourly', + function() { + Digest::send_headlines_digests(); + + return 0; + } + ); + } + static function housekeeping_common(): void { - $cache = DiskCache::instance(""); - $cache->expire_all(); - - self::migrate_feed_icons(); - self::expire_lock_files(); - self::expire_error_log(); - self::expire_feed_archive(); - self::cleanup_feed_browser(); - self::cleanup_feed_icons(); - self::disable_failed_feeds(); - - Article::_purge_orphans(); - self::cleanup_counters_cache(); + Scheduler::getInstance()->run_due_tasks(); PluginHost::getInstance()->run_hooks(PluginHost::HOOK_HOUSE_KEEPING); } |