mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-09-21 10:36:56 -04:00
* 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>
64 lines
1.9 KiB
PHP
Executable File
64 lines
1.9 KiB
PHP
Executable File
#!/usr/bin/env php
|
|
<?php
|
|
declare(strict_types=1);
|
|
require __DIR__ . '/_cli.php';
|
|
|
|
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();
|
|
}
|
|
};
|
|
|
|
if (!empty($cliOptions->errors)) {
|
|
fail('FreshRSS error: ' . array_shift($cliOptions->errors) . "\n" . $cliOptions->usage);
|
|
}
|
|
|
|
$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");
|
|
|
|
$databaseDAO = FreshRSS_Factory::createDatabaseDAO();
|
|
$databaseDAO->minorDbMaintenance();
|
|
Minz_ExtensionManager::callHookVoid(Minz_HookType::FreshrssUserMaintenance);
|
|
|
|
FreshRSS_feed_Controller::commitNewEntries();
|
|
$feedDAO = FreshRSS_Factory::createFeedDao();
|
|
$feedDAO->updateCachedValues();
|
|
|
|
$result = FreshRSS_category_Controller::refreshDynamicOpmls();
|
|
if (!empty($result['errors'])) {
|
|
$errors = $result['errors'];
|
|
fwrite(STDERR, "FreshRSS error refreshing $errors dynamic OPMLs!\n");
|
|
}
|
|
if (!empty($result['successes'])) {
|
|
$successes = $result['successes'];
|
|
echo "FreshRSS refreshed $successes dynamic OPMLs for $username\n";
|
|
}
|
|
|
|
[$nbUpdatedFeeds, , $nbNewArticles] = FreshRSS_feed_Controller::actualizeFeedsAndCommit($feedId);
|
|
|
|
echo "FreshRSS actualized $nbUpdatedFeeds feeds for $username ($nbNewArticles new articles)\n";
|
|
|
|
invalidateHttpCache($username);
|
|
|
|
done($nbUpdatedFeeds > 0);
|