summaryrefslogtreecommitdiff
path: root/classes/RSSUtils.php
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2025-05-02 10:17:13 +0300
committerAndrew Dolgov <fox@fakecake.org>2025-05-02 10:17:13 +0300
commit6a40940ad6c6facea6c8e9d0dc1896885168c442 (patch)
tree3db3b2b1035a323e655c3ff4f011c799f3b009e6 /classes/RSSUtils.php
parentf22e32a26bde89e3f3bf3ac109da1eadf6c8904c (diff)
split housekeeping jobs to separate scheduled tasks on longer cooldown intervals, add table to record task execution timestamps, bump schema
Diffstat (limited to 'classes/RSSUtils.php')
-rw-r--r--classes/RSSUtils.php95
1 files changed, 61 insertions, 34 deletions
diff --git a/classes/RSSUtils.php b/classes/RSSUtils.php
index acf1d14e5..d46d73793 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')
@@ -1432,15 +1429,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 +1647,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,21 +1715,68 @@ class RSSUtils {
}
}
- static function housekeeping_common(): void {
- $cache = DiskCache::instance("");
- $cache->expire_all();
+ /** 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...');
+
+ PluginHost::getInstance()->add_scheduled_task('purge_orphans', '@daily',
+ function() {
+ Article::_purge_orphans(); return 0;
+ }
+ );
+
+ PluginHost::getInstance()->add_scheduled_task('disk_cache_expire_all', '@daily',
+ function() {
+ $cache = DiskCache::instance("");
+ $cache->expire_all();
+
+ return 0;
+ }
+ );
+
+ PluginHost::getInstance()->add_scheduled_task('expire_error_log', '@hourly',
+ function() {
+ self::expire_error_log();
+
+ return 0;
+ }
+ );
- 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();
+ PluginHost::getInstance()->add_scheduled_task('expire_lock_files', '@hourly',
+ function() {
+ self::expire_lock_files();
- Article::_purge_orphans();
- self::cleanup_counters_cache();
+ return 0;
+ }
+ );
+
+ PluginHost::getInstance()->add_scheduled_task('disable_failed_feeds', '@daily',
+ function() {
+ self::disable_failed_feeds();
+
+ return 0;
+ }
+ );
+ PluginHost::getInstance()->add_scheduled_task('migrate_feed_icons', '@daily',
+ function() {
+ self::migrate_feed_icons();
+
+ return 0;
+ }
+ );
+
+ PluginHost::getInstance()->add_scheduled_task('cleanup_feed_icons', '@daily',
+ function() {
+ self::cleanup_feed_icons();
+
+ return 0;
+ }
+ );
+ }
+
+ static function housekeeping_common(): void {
+ PluginHost::getInstance()->run_due_tasks();
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_HOUSE_KEEPING);
}