diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-11-30 10:00:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-30 10:00:14 +0100 |
commit | 9be5caa9371bc2acad3d0b517d0aa069c6635c77 (patch) | |
tree | 993bdb8d07b232e6b7e3e9a6e549f153cad42562 | |
parent | 528516b69f8e8feaae88b033422947101f0369f5 (diff) | |
parent | 6166e1a157774b7c3c1ee8f304ef96ff2efe3e92 (diff) | |
download | nextcloud-server-9be5caa9371bc2acad3d0b517d0aa069c6635c77.tar.gz nextcloud-server-9be5caa9371bc2acad3d0b517d0aa069c6635c77.zip |
Merge pull request #24340 from nextcloud/td/psalm/job_execute
Use proper OCP\BackgroundJobs\Job
7 files changed, 19 insertions, 21 deletions
diff --git a/apps/dav/lib/BackgroundJob/RefreshWebcalJob.php b/apps/dav/lib/BackgroundJob/RefreshWebcalJob.php index 47dbbcbcaa1..32a48919868 100644 --- a/apps/dav/lib/BackgroundJob/RefreshWebcalJob.php +++ b/apps/dav/lib/BackgroundJob/RefreshWebcalJob.php @@ -30,9 +30,10 @@ declare(strict_types=1); namespace OCA\DAV\BackgroundJob; use DateInterval; -use OC\BackgroundJob\Job; use OCA\DAV\CalDAV\WebcalCaching\RefreshWebcalService; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\BackgroundJob\IJobList; +use OCP\BackgroundJob\Job; use OCP\IConfig; use OCP\ILogger; use Sabre\VObject\DateTimeParser; @@ -65,6 +66,7 @@ class RefreshWebcalJob extends Job { * @param ITimeFactory $timeFactory */ public function __construct(RefreshWebcalService $refreshWebcalService, IConfig $config, ILogger $logger, ITimeFactory $timeFactory) { + parent::__construct($timeFactory); $this->refreshWebcalService = $refreshWebcalService; $this->config = $config; $this->logger = $logger; @@ -76,7 +78,7 @@ class RefreshWebcalJob extends Job { * * @inheritdoc */ - public function execute($jobList, ILogger $logger = null) { + public function execute(IJobList $jobList, ILogger $logger = null) { $subscription = $this->refreshWebcalService->getSubscription($this->argument['principaluri'], $this->argument['uri']); if (!$subscription) { return; diff --git a/apps/dav/tests/unit/BackgroundJob/RefreshWebcalJobTest.php b/apps/dav/tests/unit/BackgroundJob/RefreshWebcalJobTest.php index f65675bccb3..c4cb52370ae 100644 --- a/apps/dav/tests/unit/BackgroundJob/RefreshWebcalJobTest.php +++ b/apps/dav/tests/unit/BackgroundJob/RefreshWebcalJobTest.php @@ -74,6 +74,7 @@ class RefreshWebcalJobTest extends TestCase { */ public function testRun(int $lastRun, int $time, bool $process) { $backgroundJob = new RefreshWebcalJob($this->refreshWebcalService, $this->config, $this->logger, $this->timeFactory); + $backgroundJob->setId(42); $backgroundJob->setArgument([ 'principaluri' => 'principals/users/testuser', @@ -99,8 +100,7 @@ class RefreshWebcalJobTest extends TestCase { ->with('dav', 'calendarSubscriptionRefreshRate', 'P1W') ->willReturn('P1W'); - $this->timeFactory->expects($this->once()) - ->method('getTime') + $this->timeFactory->method('getTime') ->willReturn($time); if ($process) { diff --git a/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php b/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php index 8af2d587fae..4949e5794b4 100644 --- a/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php +++ b/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php @@ -27,11 +27,10 @@ namespace OCA\FederatedFileSharing\BackgroundJob; -use OC\BackgroundJob\Job; -use OC\BackgroundJob\JobList; use OCA\FederatedFileSharing\AddressHandler; use OCA\FederatedFileSharing\Notifications; use OCP\BackgroundJob\IJobList; +use OCP\BackgroundJob\Job; use OCP\ILogger; /** @@ -84,10 +83,10 @@ class RetryJob extends Job { /** * run the job, then remove it from the jobList * - * @param JobList $jobList + * @param IJobList $jobList * @param ILogger|null $logger */ - public function execute($jobList, ILogger $logger = null) { + public function execute(IJobList $jobList, ILogger $logger = null) { if ($this->shouldRun($this->argument)) { parent::execute($jobList, $logger); $jobList->remove($this, $this->argument); diff --git a/apps/federation/lib/BackgroundJob/GetSharedSecret.php b/apps/federation/lib/BackgroundJob/GetSharedSecret.php index 669de02ec5c..71ea5417dd0 100644 --- a/apps/federation/lib/BackgroundJob/GetSharedSecret.php +++ b/apps/federation/lib/BackgroundJob/GetSharedSecret.php @@ -32,12 +32,11 @@ namespace OCA\Federation\BackgroundJob; use GuzzleHttp\Exception\ClientException; use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Ring\Exception\RingException; -use OC\BackgroundJob\Job; -use OC\BackgroundJob\JobList; use OCA\Federation\TrustedServers; use OCP\AppFramework\Http; use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\IJobList; +use OCP\BackgroundJob\Job; use OCP\Http\Client\IClient; use OCP\Http\Client\IClientService; use OCP\Http\Client\IResponse; @@ -115,7 +114,7 @@ class GetSharedSecret extends Job { /** * run the job, then remove it from the joblist * - * @param JobList $jobList + * @param IJobList $jobList * @param ILogger|null $logger */ public function execute(IJobList $jobList, ILogger $logger = null) { @@ -135,7 +134,7 @@ class GetSharedSecret extends Job { /** * call execute() method of parent * - * @param JobList $jobList + * @param IJobList $jobList * @param ILogger $logger */ protected function parentExecute($jobList, $logger = null) { diff --git a/apps/federation/lib/BackgroundJob/RequestSharedSecret.php b/apps/federation/lib/BackgroundJob/RequestSharedSecret.php index f577372bbae..1c9b2539b3d 100644 --- a/apps/federation/lib/BackgroundJob/RequestSharedSecret.php +++ b/apps/federation/lib/BackgroundJob/RequestSharedSecret.php @@ -31,12 +31,11 @@ namespace OCA\Federation\BackgroundJob; use GuzzleHttp\Exception\ClientException; use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Ring\Exception\RingException; -use OC\BackgroundJob\Job; -use OC\BackgroundJob\JobList; use OCA\Federation\TrustedServers; use OCP\AppFramework\Http; use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\IJobList; +use OCP\BackgroundJob\Job; use OCP\Http\Client\IClient; use OCP\Http\Client\IClientService; use OCP\ILogger; @@ -114,7 +113,7 @@ class RequestSharedSecret extends Job { /** * run the job, then remove it from the joblist * - * @param JobList $jobList + * @param IJobList $jobList * @param ILogger|null $logger */ public function execute(IJobList $jobList, ILogger $logger = null) { @@ -134,7 +133,7 @@ class RequestSharedSecret extends Job { /** * call execute() method of parent * - * @param JobList $jobList + * @param IJobList $jobList * @param ILogger $logger */ protected function parentExecute($jobList, $logger) { diff --git a/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php b/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php index 272d66e9491..889fcfd6277 100644 --- a/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php +++ b/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php @@ -95,7 +95,7 @@ class RetryJob extends Job { * @param IJobList $jobList * @param ILogger|null $logger */ - public function execute($jobList, ILogger $logger = null): void { + public function execute(IJobList $jobList, ILogger $logger = null): void { if (!isset($this->argument['userId'])) { // Old background job without user id, just drop it. $jobList->remove($this, $this->argument); diff --git a/apps/settings/lib/BackgroundJobs/VerifyUserData.php b/apps/settings/lib/BackgroundJobs/VerifyUserData.php index e77d95ff4d9..0faa9b56e82 100644 --- a/apps/settings/lib/BackgroundJobs/VerifyUserData.php +++ b/apps/settings/lib/BackgroundJobs/VerifyUserData.php @@ -30,10 +30,9 @@ namespace OCA\Settings\BackgroundJobs; use OC\Accounts\AccountManager; -use OC\BackgroundJob\Job; -use OC\BackgroundJob\JobList; use OCP\AppFramework\Http; use OCP\BackgroundJob\IJobList; +use OCP\BackgroundJob\Job; use OCP\Http\Client\IClientService; use OCP\IConfig; use OCP\ILogger; @@ -96,10 +95,10 @@ class VerifyUserData extends Job { /** * run the job, then remove it from the jobList * - * @param JobList $jobList + * @param IJobList $jobList * @param ILogger|null $logger */ - public function execute($jobList, ILogger $logger = null) { + public function execute(IJobList $jobList, ILogger $logger = null) { if ($this->shouldRun($this->argument)) { parent::execute($jobList, $logger); $jobList->remove($this, $this->argument); |