浏览代码

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 <alexandre@alapetite.fr>
Justin Tracey 4 小时之前
父节点
当前提交
3f12dcf2f6
共有 2 个文件被更改,包括 14 次插入2 次删除
  1. 1 1
      cli/README.md
  2. 13 1
      cli/actualize-user.php

+ 1 - 1
cli/README.md

@@ -101,7 +101,7 @@ cd /usr/share/FreshRSS
 ```
 ```
 
 
 ```sh
 ```sh
-./cli/actualize-user.php --user username
+./cli/actualize-user.php --user username [ --feed-id 123 ]
 # Fetch feeds for the specified user.
 # Fetch feeds for the specified user.
 
 
 ./cli/delete-user.php --user username
 ./cli/delete-user.php --user username

+ 13 - 1
cli/actualize-user.php

@@ -7,9 +7,11 @@ performRequirementCheck(FreshRSS_Context::systemConf()->db['type'] ?? '');
 
 
 $cliOptions = new class extends CliOptionsParser {
 $cliOptions = new class extends CliOptionsParser {
 	public string $user;
 	public string $user;
+	public string $feedId = '';
 
 
 	public function __construct() {
 	public function __construct() {
 		$this->addRequiredOption('user', (new CliOption('user')));
 		$this->addRequiredOption('user', (new CliOption('user')));
+		$this->addOption('feedId', (new CliOption('feed-id')));
 		parent::__construct();
 		parent::__construct();
 	}
 	}
 };
 };
@@ -20,6 +22,16 @@ if (!empty($cliOptions->errors)) {
 
 
 $username = cliInitUser($cliOptions->user);
 $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);
 Minz_ExtensionManager::callHookVoid(Minz_HookType::FreshrssUserMaintenance);
 
 
 fwrite(STDERR, 'FreshRSS actualizing user “' . $username . "”…\n");
 fwrite(STDERR, 'FreshRSS actualizing user “' . $username . "”…\n");
@@ -42,7 +54,7 @@ if (!empty($result['successes'])) {
 	echo "FreshRSS refreshed $successes dynamic OPMLs for $username\n";
 	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";
 echo "FreshRSS actualized $nbUpdatedFeeds feeds for $username ($nbNewArticles new articles)\n";