summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2020-12-15 13:48:38 +0100
committerGitHub <noreply@github.com>2020-12-15 13:48:38 +0100
commite196cc0e2afeb6299824fb74a6176b59a75764fd (patch)
tree0cb28e78e4ceb3c41340ab5de9b00b4f83c154a0 /apps
parent8506d0864b3a017baeed2ad5f9a032ae1d7a6734 (diff)
parent11c1ce6974aad825c3ea033eaa35869d21cf88e4 (diff)
downloadnextcloud-server-e196cc0e2afeb6299824fb74a6176b59a75764fd.tar.gz
nextcloud-server-e196cc0e2afeb6299824fb74a6176b59a75764fd.zip
Merge pull request #24695 from nextcloud/bugfix/24340/fix-missing-parent-constructor-calls
Add missing parent::__construct() calls to Jobs
Diffstat (limited to 'apps')
-rw-r--r--apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php34
-rw-r--r--apps/federation/lib/BackgroundJob/GetSharedSecret.php11
-rw-r--r--apps/federation/lib/BackgroundJob/RequestSharedSecret.php11
-rw-r--r--apps/settings/lib/BackgroundJobs/VerifyUserData.php12
4 files changed, 19 insertions, 49 deletions
diff --git a/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php b/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php
index 4949e5794b4..d79fb83a958 100644
--- a/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php
+++ b/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php
@@ -27,8 +27,8 @@
namespace OCA\FederatedFileSharing\BackgroundJob;
-use OCA\FederatedFileSharing\AddressHandler;
use OCA\FederatedFileSharing\Notifications;
+use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\BackgroundJob\Job;
use OCP\ILogger;
@@ -55,29 +55,11 @@ class RetryJob extends Job {
/** @var int how much time should be between two tries (10 minutes) */
private $interval = 600;
- /**
- * UnShare constructor.
- *
- * @param Notifications $notifications
- */
- public function __construct(Notifications $notifications = null) {
- if ($notifications) {
- $this->notifications = $notifications;
- } else {
- $addressHandler = new AddressHandler(
- \OC::$server->getURLGenerator(),
- \OC::$server->getL10N('federatedfilesharing'),
- \OC::$server->getCloudIdManager()
- );
- $this->notifications = new Notifications(
- $addressHandler,
- \OC::$server->getHTTPClientService(),
- \OC::$server->query(\OCP\OCS\IDiscoveryService::class),
- \OC::$server->getJobList(),
- \OC::$server->getCloudFederationProviderManager(),
- \OC::$server->getCloudFederationFactory()
- );
- }
+
+ public function __construct(Notifications $notifications,
+ ITimeFactory $timeFactory) {
+ parent::__construct($timeFactory);
+ $this->notifications = $notifications;
}
/**
@@ -126,7 +108,7 @@ class RetryJob extends Job {
'data' => $argument['data'],
'action' => $argument['action'],
'try' => (int)$argument['try'] + 1,
- 'lastRun' => time()
+ 'lastRun' => $this->time->getTime()
]
);
}
@@ -139,6 +121,6 @@ class RetryJob extends Job {
*/
protected function shouldRun(array $argument) {
$lastRun = (int)$argument['lastRun'];
- return ((time() - $lastRun) > $this->interval);
+ return (($this->time->getTime() - $lastRun) > $this->interval);
}
}
diff --git a/apps/federation/lib/BackgroundJob/GetSharedSecret.php b/apps/federation/lib/BackgroundJob/GetSharedSecret.php
index 71ea5417dd0..9390b047a91 100644
--- a/apps/federation/lib/BackgroundJob/GetSharedSecret.php
+++ b/apps/federation/lib/BackgroundJob/GetSharedSecret.php
@@ -71,9 +71,6 @@ class GetSharedSecret extends Job {
/** @var ILogger */
private $logger;
- /** @var ITimeFactory */
- private $timeFactory;
-
/** @var bool */
protected $retainJob = false;
@@ -102,13 +99,13 @@ class GetSharedSecret extends Job {
IDiscoveryService $ocsDiscoveryService,
ITimeFactory $timeFactory
) {
+ parent::__construct($timeFactory);
$this->logger = $logger;
$this->httpClient = $httpClientService->newClient();
$this->jobList = $jobList;
$this->urlGenerator = $urlGenerator;
$this->ocsDiscoveryService = $ocsDiscoveryService;
$this->trustedServers = $trustedServers;
- $this->timeFactory = $timeFactory;
}
/**
@@ -143,8 +140,8 @@ class GetSharedSecret extends Job {
protected function run($argument) {
$target = $argument['url'];
- $created = isset($argument['created']) ? (int)$argument['created'] : $this->timeFactory->getTime();
- $currentTime = $this->timeFactory->getTime();
+ $created = isset($argument['created']) ? (int)$argument['created'] : $this->time->getTime();
+ $currentTime = $this->time->getTime();
$source = $this->urlGenerator->getAbsoluteURL('/');
$source = rtrim($source, '/');
$token = $argument['token'];
@@ -239,7 +236,7 @@ class GetSharedSecret extends Job {
*/
protected function reAddJob(array $argument) {
$url = $argument['url'];
- $created = isset($argument['created']) ? (int)$argument['created'] : $this->timeFactory->getTime();
+ $created = isset($argument['created']) ? (int)$argument['created'] : $this->time->getTime();
$token = $argument['token'];
$this->jobList->add(
GetSharedSecret::class,
diff --git a/apps/federation/lib/BackgroundJob/RequestSharedSecret.php b/apps/federation/lib/BackgroundJob/RequestSharedSecret.php
index 1c9b2539b3d..c9bee9fa6be 100644
--- a/apps/federation/lib/BackgroundJob/RequestSharedSecret.php
+++ b/apps/federation/lib/BackgroundJob/RequestSharedSecret.php
@@ -69,9 +69,6 @@ class RequestSharedSecret extends Job {
/** @var ILogger */
private $logger;
- /** @var ITimeFactory */
- private $timeFactory;
-
/** @var bool */
protected $retainJob = false;
@@ -100,13 +97,13 @@ class RequestSharedSecret extends Job {
ILogger $logger,
ITimeFactory $timeFactory
) {
+ parent::__construct($timeFactory);
$this->httpClient = $httpClientService->newClient();
$this->jobList = $jobList;
$this->urlGenerator = $urlGenerator;
$this->logger = $logger;
$this->ocsDiscoveryService = $ocsDiscoveryService;
$this->trustedServers = $trustedServers;
- $this->timeFactory = $timeFactory;
}
@@ -142,8 +139,8 @@ class RequestSharedSecret extends Job {
protected function run($argument) {
$target = $argument['url'];
- $created = isset($argument['created']) ? (int)$argument['created'] : $this->timeFactory->getTime();
- $currentTime = $this->timeFactory->getTime();
+ $created = isset($argument['created']) ? (int)$argument['created'] : $this->time->getTime();
+ $currentTime = $this->time->getTime();
$source = $this->urlGenerator->getAbsoluteURL('/');
$source = rtrim($source, '/');
$token = $argument['token'];
@@ -211,7 +208,7 @@ class RequestSharedSecret extends Job {
*/
protected function reAddJob(array $argument) {
$url = $argument['url'];
- $created = isset($argument['created']) ? (int)$argument['created'] : $this->timeFactory->getTime();
+ $created = isset($argument['created']) ? (int)$argument['created'] : $this->time->getTime();
$token = $argument['token'];
$this->jobList->add(
diff --git a/apps/settings/lib/BackgroundJobs/VerifyUserData.php b/apps/settings/lib/BackgroundJobs/VerifyUserData.php
index d1b6d835fa4..cb671f33466 100644
--- a/apps/settings/lib/BackgroundJobs/VerifyUserData.php
+++ b/apps/settings/lib/BackgroundJobs/VerifyUserData.php
@@ -32,6 +32,7 @@ namespace OCA\Settings\BackgroundJobs;
use OC\Accounts\AccountManager;
use OCP\Accounts\IAccountManager;
use OCP\AppFramework\Http;
+use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\BackgroundJob\Job;
use OCP\Http\Client\IClientService;
@@ -68,21 +69,14 @@ class VerifyUserData extends Job {
/** @var IConfig */
private $config;
- /**
- * VerifyUserData constructor.
- *
- * @param AccountManager $accountManager
- * @param IUserManager $userManager
- * @param IClientService $clientService
- * @param ILogger $logger
- * @param IConfig $config
- */
public function __construct(AccountManager $accountManager,
IUserManager $userManager,
IClientService $clientService,
ILogger $logger,
+ ITimeFactory $timeFactory,
IConfig $config
) {
+ parent::__construct($timeFactory);
$this->accountManager = $accountManager;
$this->userManager = $userManager;
$this->httpClientService = $clientService;