From 44b5b33f3da9012e0028de6230ccbd5a729a4b71 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 2 May 2025 10:28:35 +0300 Subject: remove synchronous usages of _purge_orphans() --- classes/RPC.php | 6 ------ 1 file changed, 6 deletions(-) (limited to 'classes/RPC.php') diff --git a/classes/RPC.php b/classes/RPC.php index 6b6f3e909..c6cdab7f6 100644 --- a/classes/RPC.php +++ b/classes/RPC.php @@ -82,8 +82,6 @@ class RPC extends Handler_Protected { WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?"); $sth->execute([...$ids, $_SESSION['uid']]); - Article::_purge_orphans(); - print json_encode(array("message" => "UPDATE_COUNTERS")); } @@ -311,10 +309,6 @@ class RPC extends Handler_Protected { } } - // Purge orphans and cleanup tags - Article::_purge_orphans(); - //cleanup_tags(14, 50000); - if ($num_updated > 0) { print json_encode(array("message" => "UPDATE_COUNTERS", "num_updated" => $num_updated)); -- cgit v1.2.3-54-g00ecf From aeca30cb0c6b26c569f66c5043690d5528fc481b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 2 May 2025 13:26:58 +0300 Subject: drop SIMPLE_UPDATE_MODE, limit housekeeping and updates to background processes --- backend.php | 2 +- classes/Config.php | 8 ------ classes/Handler_Public.php | 14 --------- classes/RPC.php | 72 ---------------------------------------------- classes/RSSUtils.php | 1 - js/App.js | 5 ---- js/Feeds.js | 7 ----- 7 files changed, 1 insertion(+), 108 deletions(-) (limited to 'classes/RPC.php') diff --git a/backend.php b/backend.php index 860a3940c..d9a0af7c7 100644 --- a/backend.php +++ b/backend.php @@ -14,7 +14,7 @@ /* Public calls compatibility shim */ - $public_calls = array("globalUpdateFeeds", "rss", "getUnread", "getProfiles", "share"); + $public_calls = array("rss", "getUnread", "getProfiles", "share"); if (array_search($op, $public_calls) !== false) { header("Location: public.php?" . $_SERVER['QUERY_STRING']); diff --git a/classes/Config.php b/classes/Config.php index 1afa4f043..c413317be 100644 --- a/classes/Config.php +++ b/classes/Config.php @@ -53,13 +53,6 @@ class Config { * your tt-rss directory protected by other means (e.g. http auth). */ const SINGLE_USER_MODE = "SINGLE_USER_MODE"; - /** enables fallback update mode where tt-rss tries to update feeds in - * background while tt-rss is open in your browser. - * if you don't have a lot of feeds and don't want to or can't run - * background processes while not running tt-rss, this method is generally - * viable to keep your feeds up to date. */ - const SIMPLE_UPDATE_MODE = "SIMPLE_UPDATE_MODE"; - /** use this PHP CLI executable to start various tasks */ const PHP_EXECUTABLE = "PHP_EXECUTABLE"; @@ -205,7 +198,6 @@ class Config { Config::DB_PORT => [ "5432", Config::T_STRING ], Config::SELF_URL_PATH => [ "https://example.com/tt-rss", Config::T_STRING ], Config::SINGLE_USER_MODE => [ "", Config::T_BOOL ], - Config::SIMPLE_UPDATE_MODE => [ "", Config::T_BOOL ], Config::PHP_EXECUTABLE => [ "/usr/bin/php", Config::T_STRING ], Config::LOCK_DIRECTORY => [ "lock", Config::T_STRING ], Config::CACHE_DIR => [ "cache", Config::T_STRING ], diff --git a/classes/Handler_Public.php b/classes/Handler_Public.php index abff08376..bb3667e2a 100644 --- a/classes/Handler_Public.php +++ b/classes/Handler_Public.php @@ -360,20 +360,6 @@ class Handler_Public extends Handler { header('HTTP/1.1 403 Forbidden'); } - function updateTask(): void { - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK); - } - - function housekeepingTask(): void { - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_HOUSE_KEEPING); - } - - function globalUpdateFeeds(): void { - RPC::updaterandomfeed_real(); - - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK); - } - function login(): void { if (!Config::get(Config::SINGLE_USER_MODE)) { diff --git a/classes/RPC.php b/classes/RPC.php index c6cdab7f6..4d133c272 100644 --- a/classes/RPC.php +++ b/classes/RPC.php @@ -250,77 +250,6 @@ class RPC extends Handler_Protected { print json_encode(["wide" => $wide]); } - static function updaterandomfeed_real(): void { - $default_interval = (int) Prefs::get_default(Prefs::DEFAULT_UPDATE_INTERVAL); - - // Test if the feed need a update (update interval exceded). - $update_limit_qpart = "AND (( - update_interval = 0 - AND (p.value IS NULL OR p.value != '-1') - AND last_updated < NOW() - CAST((COALESCE(p.value, '$default_interval') || ' minutes') AS INTERVAL) - ) OR ( - update_interval > 0 - AND last_updated < NOW() - CAST((update_interval || ' minutes') AS INTERVAL) - ) OR ( - update_interval >= 0 - AND (p.value IS NULL OR p.value != '-1') - AND (last_updated = '1970-01-01 00:00:00' OR last_updated IS NULL) - ))"; - - // Test if feed is currently being updated by another process. - $updstart_thresh_qpart = 'AND (last_update_started IS NULL OR ' - . Db::past_comparison_qpart('last_update_started', '<', 5, 'minute') . ')'; - - $pdo = Db::pdo(); - - // we could be invoked from public.php with no active session - if (!empty($_SESSION["uid"])) { - $owner_check_qpart = "AND f.owner_uid = ".$pdo->quote($_SESSION["uid"]); - } else { - $owner_check_qpart = ""; - } - - $query = "SELECT f.feed_url,f.id - FROM - ttrss_feeds f, ttrss_users u LEFT JOIN ttrss_user_prefs2 p ON - (p.owner_uid = u.id AND profile IS NULL AND pref_name = 'DEFAULT_UPDATE_INTERVAL') - WHERE - f.owner_uid = u.id AND - u.access_level NOT IN (".sprintf("%d, %d", UserHelper::ACCESS_LEVEL_DISABLED, UserHelper::ACCESS_LEVEL_READONLY).") - $owner_check_qpart - $update_limit_qpart - $updstart_thresh_qpart - ORDER BY RANDOM() LIMIT 30"; - - $res = $pdo->query($query); - - $num_updated = 0; - - $tstart = time(); - - while ($line = $res->fetch()) { - $feed_id = $line["id"]; - - if (time() - $tstart < ini_get("max_execution_time") * 0.7) { - RSSUtils::update_rss_feed($feed_id, true); - ++$num_updated; - } else { - break; - } - } - - if ($num_updated > 0) { - print json_encode(array("message" => "UPDATE_COUNTERS", - "num_updated" => $num_updated)); - } else { - print json_encode(array("message" => "NOTHING_TO_UPDATE")); - } - } - - function updaterandomfeed(): void { - self::updaterandomfeed_real(); - } - /** * @param array $ids */ @@ -466,7 +395,6 @@ class RPC extends Handler_Protected { $params["num_feeds"] = (int) $num_feeds; $params["hotkeys"] = $this->get_hotkeys_map(); $params["widescreen"] = (int) Prefs::get(Prefs::WIDESCREEN_MODE, $_SESSION['uid'], $profile); - $params['simple_update'] = Config::get(Config::SIMPLE_UPDATE_MODE); $params["icon_indicator_white"] = $this->image_to_base64("images/indicator_white.gif"); $params["icon_oval"] = $this->image_to_base64("images/oval.svg"); $params["icon_three_dots"] = $this->image_to_base64("images/three-dots.svg"); diff --git a/classes/RSSUtils.php b/classes/RSSUtils.php index 67ee3709d..eef0d8540 100644 --- a/classes/RSSUtils.php +++ b/classes/RSSUtils.php @@ -129,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') . ')'; diff --git a/js/App.js b/js/App.js index 0c4c72f22..f1c4bc1c3 100644 --- a/js/App.js +++ b/js/App.js @@ -829,11 +829,6 @@ const App = { Headlines.initScrollHandler(); - if (this.getInitParam("simple_update")) { - console.log("scheduling simple feed updater..."); - window.setInterval(() => { Feeds.updateRandom() }, 30 * 1000); - } - if (this.getInitParam('check_for_updates')) { window.setInterval(() => { this.checkForUpdates(); diff --git a/js/Feeds.js b/js/Feeds.js index 9088b7efc..7a58a10a4 100644 --- a/js/Feeds.js +++ b/js/Feeds.js @@ -743,13 +743,6 @@ const Feeds = { dialog.show(); }, - updateRandom: function() { - console.log("in update_random_feed"); - - xhr.json("backend.php", {op: "RPC", method: "updaterandomfeed"}, () => { - // - }); - }, renderIcon: function(feed_id, exists) { const icon_url = App.getInitParam("icons_url") + '?' + dojo.objectToQuery({op: 'feed_icon', id: feed_id}); -- cgit v1.2.3-54-g00ecf From b30f8c93a00ce1ae2c582ca4c7f1d5d8425220ee Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 2 May 2025 21:27:50 +0300 Subject: rename article mark/publish hooks --- classes/API.php | 4 ++-- classes/Article.php | 6 +++--- classes/Plugin.php | 7 +++++-- classes/PluginHost.php | 8 ++++---- classes/RPC.php | 8 ++++---- classes/RSSUtils.php | 4 ++-- 6 files changed, 20 insertions(+), 17 deletions(-) (limited to 'classes/RPC.php') diff --git a/classes/API.php b/classes/API.php index 83eaa22b8..6db05198a 100644 --- a/classes/API.php +++ b/classes/API.php @@ -285,10 +285,10 @@ class API extends Handler { $sth->execute([...$article_ids, $_SESSION['uid']]); if ($field == 'marked') - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_MARKED, $article_ids); + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_MARK_TOGGLED, $article_ids); if ($field == 'published') - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_PUBLISHED, $article_ids); + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_PUBLISH_TOGGLED, $article_ids); $num_updated = $sth->rowCount(); diff --git a/classes/Article.php b/classes/Article.php index 6a3111892..c0d77123c 100644 --- a/classes/Article.php +++ b/classes/Article.php @@ -98,7 +98,7 @@ class Article extends Handler_Protected { int_id = ? AND owner_uid = ?"); $sth->execute([$int_id, $owner_uid]); - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_PUBLISHED, [$ref_id]); + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_PUBLISH_TOGGLED, [$ref_id]); } else { @@ -109,7 +109,7 @@ class Article extends Handler_Protected { (?, '', NULL, NULL, ?, true, '', '', NOW(), '', false, NOW())"); $sth->execute([$ref_id, $owner_uid]); - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_PUBLISHED, [$ref_id]); + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_PUBLISH_TOGGLED, [$ref_id]); } if (count($labels) != 0) { @@ -148,7 +148,7 @@ class Article extends Handler_Protected { (?, '', NULL, NULL, ?, true, '', '', NOW(), '', false, NOW())"); $sth->execute([$ref_id, $owner_uid]); - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_PUBLISHED, [$ref_id]); + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_PUBLISH_TOGGLED, [$ref_id]); if (count($labels) != 0) { foreach ($labels as $label) { diff --git a/classes/Plugin.php b/classes/Plugin.php index b66e2082c..3165d62f4 100644 --- a/classes/Plugin.php +++ b/classes/Plugin.php @@ -714,22 +714,25 @@ abstract class Plugin { } /** Invoked after passed article IDs were either marked (i.e. starred) or unmarked. + * * **Note** resulting state of the articles is not passed to this function (because * tt-rss may do invert operation on ID range), you will need to get this from the database. * @param array $article_ids ref_ids * @return void */ - function hook_articles_marked(array $article_ids) { + function hook_articles_mark_toggled(array $article_ids) { user_error("Dummy method invoked.", E_USER_ERROR); } /** Invoked after passed article IDs were either published or unpublished. + * * **Note** resulting state of the articles is not passed to this function (because * tt-rss may do invert operation on ID range), you will need to get this from the database. + * * @param array $article_ids ref_ids * @return void */ - function hook_articles_published(array $article_ids) { + function hook_articles_publish_toggled(array $article_ids) { user_error("Dummy method invoked.", E_USER_ERROR); } } diff --git a/classes/PluginHost.php b/classes/PluginHost.php index 8bde8df3f..5cff4afcb 100644 --- a/classes/PluginHost.php +++ b/classes/PluginHost.php @@ -202,11 +202,11 @@ class PluginHost { /** @see Plugin::hook_validate_session() */ const HOOK_VALIDATE_SESSION = "hook_validate_session"; - /** @see Plugin::hook_articles_marked() */ - const HOOK_ARTICLES_MARKED = "hook_articles_marked"; + /** @see Plugin::hook_articles_mark_toggled() */ + const HOOK_ARTICLES_MARK_TOGGLED = "hook_articles_mark_toggled"; - /** @see Plugin::hook_articles_published() */ - const HOOK_ARTICLES_PUBLISHED = "hook_articles_published"; + /** @see Plugin::hook_articles_publish_toggled() */ + const HOOK_ARTICLES_PUBLISH_TOGGLED = "hook_articles_publish_toggled"; const KIND_ALL = 1; const KIND_SYSTEM = 2; diff --git a/classes/RPC.php b/classes/RPC.php index 4d133c272..6ce2c12aa 100644 --- a/classes/RPC.php +++ b/classes/RPC.php @@ -69,7 +69,7 @@ class RPC extends Handler_Protected { $sth->execute([$mark, $id, $_SESSION['uid']]); - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_MARKED, [$id]); + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_MARK_TOGGLED, [$id]); print json_encode(array("message" => "UPDATE_COUNTERS")); } @@ -95,7 +95,7 @@ class RPC extends Handler_Protected { $sth->execute([$pub, $id, $_SESSION['uid']]); - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_PUBLISHED, [$id]); + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_PUBLISH_TOGGLED, [$id]); print json_encode(array("message" => "UPDATE_COUNTERS")); } @@ -273,7 +273,7 @@ class RPC extends Handler_Protected { $sth->execute([...$ids, $_SESSION['uid']]); - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_MARKED, $ids); + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_MARK_TOGGLED, $ids); } /** @@ -299,7 +299,7 @@ class RPC extends Handler_Protected { $sth->execute([...$ids, $_SESSION['uid']]); - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_PUBLISHED, $ids); + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_PUBLISH_TOGGLED, $ids); } function log(): void { diff --git a/classes/RSSUtils.php b/classes/RSSUtils.php index eef0d8540..575a1eda1 100644 --- a/classes/RSSUtils.php +++ b/classes/RSSUtils.php @@ -1126,10 +1126,10 @@ class RSSUtils { $published, $score]); if ($marked) - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_MARKED, [$ref_id]); + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_MARK_TOGGLED, [$ref_id]); if ($published) - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_PUBLISHED, [$ref_id]); + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_ARTICLES_PUBLISH_TOGGLED, [$ref_id]); $sth = $pdo->prepare("SELECT int_id FROM ttrss_user_entries WHERE ref_id = ? AND owner_uid = ? AND -- cgit v1.2.3-54-g00ecf