diff options
author | Benjamin Brahmer <info@b-brahmer.de> | 2023-03-02 16:19:49 +0100 |
---|---|---|
committer | Benjamin Brahmer <info@b-brahmer.de> | 2023-03-02 17:51:53 +0100 |
commit | 04fcda9b1a1016e08316e14fef182d1955b5e4e6 (patch) | |
tree | 5ad794c638964d67eb4ce039d7e1dcc359280434 | |
parent | e6117020c05adc2fbd7bdf724766cdf523ff7a93 (diff) |
Remove unused job from db
Our background job was renamed quite a while ago
the old job remained in the db, to prevent confusion this adds
a repair step to remove the old job.
Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | appinfo/info.xml | 6 | ||||
-rw-r--r-- | lib/Migration/RemoveUnusedJob.php | 51 |
3 files changed, 58 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index b6e269cb5..bd5513549 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ The format is mostly based on [Keep a Changelog](https://keepachangelog.com/en/1 # Unreleased ## [21.x.x] ### Changed - +- Remove unused background job OCA\News\Cron\Updater ### Fixed # Releases diff --git a/appinfo/info.xml b/appinfo/info.xml index 912fcabc8..8e06ff9bb 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -62,6 +62,12 @@ Report a [feed issue](https://github.com/nextcloud/news/discussions/new) <job>OCA\News\Cron\UpdaterJob</job> </background-jobs> + <repair-steps> + <post-migration> + <step>OCA\News\Migration\RemoveUnusedJob</step> + </post-migration> + </repair-steps> + <commands> <command>OCA\News\Command\ExploreGenerator</command> <command>OCA\News\Command\ShowFeed</command> diff --git a/lib/Migration/RemoveUnusedJob.php b/lib/Migration/RemoveUnusedJob.php new file mode 100644 index 000000000..b0202f5a4 --- /dev/null +++ b/lib/Migration/RemoveUnusedJob.php @@ -0,0 +1,51 @@ +<?php +namespace OCA\News\Migration; + +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; +use Psr\Log\LoggerInterface; +use OCP\BackgroundJob\IJobList; + +class RemoveUnusedJob implements IRepairStep +{ + + /** + * @var LoggerInterface + */ + protected $logger; + + /** + * @var IJobList + */ + protected $joblist; + + public function __construct(LoggerInterface $logger, IJobList $jobList) + { + + $this->logger = $logger; + $this->joblist = $jobList; + } + + /** + * Returns the step's name + */ + public function getName() + { + return 'Remove the unused News update job'; + } + + /** + * @param IOutput $output + */ + public function run(IOutput $output) + { + if($this->joblist->has("OCA\News\Cron\Updater", null)){ + $output->info("Job exists, attempting to remove"); + $this->joblist->remove("OCA\News\Cron\Updater"); + $output->info("Job removed"); + } else { + $output->info("Job does not exist, all good"); + } + + } +}
\ No newline at end of file |