From 3f12dcf2f60daa1aa81f670672e89c73c1b72012 Mon Sep 17 00:00:00 2001 From: Justin Tracey Date: Sat, 19 Sep 2026 04:01:32 -0400 Subject: [PATCH] Add optional feed argument to actualize-user.php (#9319) * Add optional feed argument to actualize-user.php Ports the change in #9182 from actualize_script.php to actualize-user.php, as suggested. Adds an optional argument to the script to allow updating a particular feed, instead of all of them. This makes it easier to update specific feeds via cron and other local utilities. (My personal motivation is to add a bit of privacy to updates so they aren't as obviously linked, but this is also useful for other reasons, e.g. if you have too many feeds to feasibly update at once.) * Doc + minor type check preference --------- Co-authored-by: Alexandre Alapetite --- cli/README.md | 2 +- cli/actualize-user.php | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/cli/README.md b/cli/README.md index 85ebb0e28..90c489c13 100644 --- a/cli/README.md +++ b/cli/README.md @@ -101,7 +101,7 @@ cd /usr/share/FreshRSS ``` ```sh -./cli/actualize-user.php --user username +./cli/actualize-user.php --user username [ --feed-id 123 ] # Fetch feeds for the specified user. ./cli/delete-user.php --user username diff --git a/cli/actualize-user.php b/cli/actualize-user.php index 77254d834..eea6106f9 100755 --- a/cli/actualize-user.php +++ b/cli/actualize-user.php @@ -7,9 +7,11 @@ performRequirementCheck(FreshRSS_Context::systemConf()->db['type'] ?? ''); $cliOptions = new class extends CliOptionsParser { public string $user; + public string $feedId = ''; public function __construct() { $this->addRequiredOption('user', (new CliOption('user'))); + $this->addOption('feedId', (new CliOption('feed-id'))); parent::__construct(); } }; @@ -20,6 +22,16 @@ if (!empty($cliOptions->errors)) { $username = cliInitUser($cliOptions->user); +$feedId = null; +if ($cliOptions->feedId !== '') { + $feedId = filter_var($cliOptions->feedId, FILTER_VALIDATE_INT, [ + 'options' => ['min_range' => 1], + ]); + if (!is_int($feedId)) { + fail('FreshRSS error: Invalid feed ID: ' . $cliOptions->feedId . "\n"); + } +} + Minz_ExtensionManager::callHookVoid(Minz_HookType::FreshrssUserMaintenance); fwrite(STDERR, 'FreshRSS actualizing user “' . $username . "”…\n"); @@ -42,7 +54,7 @@ if (!empty($result['successes'])) { echo "FreshRSS refreshed $successes dynamic OPMLs for $username\n"; } -[$nbUpdatedFeeds, , $nbNewArticles] = FreshRSS_feed_Controller::actualizeFeedsAndCommit(); +[$nbUpdatedFeeds, , $nbNewArticles] = FreshRSS_feed_Controller::actualizeFeedsAndCommit($feedId); echo "FreshRSS actualized $nbUpdatedFeeds feeds for $username ($nbNewArticles new articles)\n";