Skip to content

Commit e196cc0

Browse files
Merge pull request #24695 from nextcloud/bugfix/24340/fix-missing-parent-constructor-calls
Add missing parent::__construct() calls to Jobs
2 parents 8506d08 + 11c1ce6 commit e196cc0

File tree

4 files changed

+19
-49
lines changed

4 files changed

+19
-49
lines changed

apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
namespace OCA\FederatedFileSharing\BackgroundJob;
2929

30-
use OCA\FederatedFileSharing\AddressHandler;
3130
use OCA\FederatedFileSharing\Notifications;
31+
use OCP\AppFramework\Utility\ITimeFactory;
3232
use OCP\BackgroundJob\IJobList;
3333
use OCP\BackgroundJob\Job;
3434
use OCP\ILogger;
@@ -55,29 +55,11 @@ class RetryJob extends Job {
5555
/** @var int how much time should be between two tries (10 minutes) */
5656
private $interval = 600;
5757

58-
/**
59-
* UnShare constructor.
60-
*
61-
* @param Notifications $notifications
62-
*/
63-
public function __construct(Notifications $notifications = null) {
64-
if ($notifications) {
65-
$this->notifications = $notifications;
66-
} else {
67-
$addressHandler = new AddressHandler(
68-
\OC::$server->getURLGenerator(),
69-
\OC::$server->getL10N('federatedfilesharing'),
70-
\OC::$server->getCloudIdManager()
71-
);
72-
$this->notifications = new Notifications(
73-
$addressHandler,
74-
\OC::$server->getHTTPClientService(),
75-
\OC::$server->query(\OCP\OCS\IDiscoveryService::class),
76-
\OC::$server->getJobList(),
77-
\OC::$server->getCloudFederationProviderManager(),
78-
\OC::$server->getCloudFederationFactory()
79-
);
80-
}
58+
59+
public function __construct(Notifications $notifications,
60+
ITimeFactory $timeFactory) {
61+
parent::__construct($timeFactory);
62+
$this->notifications = $notifications;
8163
}
8264

8365
/**
@@ -126,7 +108,7 @@ protected function reAddJob(IJobList $jobList, array $argument) {
126108
'data' => $argument['data'],
127109
'action' => $argument['action'],
128110
'try' => (int)$argument['try'] + 1,
129-
'lastRun' => time()
111+
'lastRun' => $this->time->getTime()
130112
]
131113
);
132114
}
@@ -139,6 +121,6 @@ protected function reAddJob(IJobList $jobList, array $argument) {
139121
*/
140122
protected function shouldRun(array $argument) {
141123
$lastRun = (int)$argument['lastRun'];
142-
return ((time() - $lastRun) > $this->interval);
124+
return (($this->time->getTime() - $lastRun) > $this->interval);
143125
}
144126
}

apps/federation/lib/BackgroundJob/GetSharedSecret.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ class GetSharedSecret extends Job {
7171
/** @var ILogger */
7272
private $logger;
7373

74-
/** @var ITimeFactory */
75-
private $timeFactory;
76-
7774
/** @var bool */
7875
protected $retainJob = false;
7976

@@ -102,13 +99,13 @@ public function __construct(
10299
IDiscoveryService $ocsDiscoveryService,
103100
ITimeFactory $timeFactory
104101
) {
102+
parent::__construct($timeFactory);
105103
$this->logger = $logger;
106104
$this->httpClient = $httpClientService->newClient();
107105
$this->jobList = $jobList;
108106
$this->urlGenerator = $urlGenerator;
109107
$this->ocsDiscoveryService = $ocsDiscoveryService;
110108
$this->trustedServers = $trustedServers;
111-
$this->timeFactory = $timeFactory;
112109
}
113110

114111
/**
@@ -143,8 +140,8 @@ protected function parentExecute($jobList, $logger = null) {
143140

144141
protected function run($argument) {
145142
$target = $argument['url'];
146-
$created = isset($argument['created']) ? (int)$argument['created'] : $this->timeFactory->getTime();
147-
$currentTime = $this->timeFactory->getTime();
143+
$created = isset($argument['created']) ? (int)$argument['created'] : $this->time->getTime();
144+
$currentTime = $this->time->getTime();
148145
$source = $this->urlGenerator->getAbsoluteURL('/');
149146
$source = rtrim($source, '/');
150147
$token = $argument['token'];
@@ -239,7 +236,7 @@ protected function run($argument) {
239236
*/
240237
protected function reAddJob(array $argument) {
241238
$url = $argument['url'];
242-
$created = isset($argument['created']) ? (int)$argument['created'] : $this->timeFactory->getTime();
239+
$created = isset($argument['created']) ? (int)$argument['created'] : $this->time->getTime();
243240
$token = $argument['token'];
244241
$this->jobList->add(
245242
GetSharedSecret::class,

apps/federation/lib/BackgroundJob/RequestSharedSecret.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ class RequestSharedSecret extends Job {
6969
/** @var ILogger */
7070
private $logger;
7171

72-
/** @var ITimeFactory */
73-
private $timeFactory;
74-
7572
/** @var bool */
7673
protected $retainJob = false;
7774

@@ -100,13 +97,13 @@ public function __construct(
10097
ILogger $logger,
10198
ITimeFactory $timeFactory
10299
) {
100+
parent::__construct($timeFactory);
103101
$this->httpClient = $httpClientService->newClient();
104102
$this->jobList = $jobList;
105103
$this->urlGenerator = $urlGenerator;
106104
$this->logger = $logger;
107105
$this->ocsDiscoveryService = $ocsDiscoveryService;
108106
$this->trustedServers = $trustedServers;
109-
$this->timeFactory = $timeFactory;
110107
}
111108

112109

@@ -142,8 +139,8 @@ protected function parentExecute($jobList, $logger) {
142139

143140
protected function run($argument) {
144141
$target = $argument['url'];
145-
$created = isset($argument['created']) ? (int)$argument['created'] : $this->timeFactory->getTime();
146-
$currentTime = $this->timeFactory->getTime();
142+
$created = isset($argument['created']) ? (int)$argument['created'] : $this->time->getTime();
143+
$currentTime = $this->time->getTime();
147144
$source = $this->urlGenerator->getAbsoluteURL('/');
148145
$source = rtrim($source, '/');
149146
$token = $argument['token'];
@@ -211,7 +208,7 @@ protected function run($argument) {
211208
*/
212209
protected function reAddJob(array $argument) {
213210
$url = $argument['url'];
214-
$created = isset($argument['created']) ? (int)$argument['created'] : $this->timeFactory->getTime();
211+
$created = isset($argument['created']) ? (int)$argument['created'] : $this->time->getTime();
215212
$token = $argument['token'];
216213

217214
$this->jobList->add(

apps/settings/lib/BackgroundJobs/VerifyUserData.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use OC\Accounts\AccountManager;
3333
use OCP\Accounts\IAccountManager;
3434
use OCP\AppFramework\Http;
35+
use OCP\AppFramework\Utility\ITimeFactory;
3536
use OCP\BackgroundJob\IJobList;
3637
use OCP\BackgroundJob\Job;
3738
use OCP\Http\Client\IClientService;
@@ -68,21 +69,14 @@ class VerifyUserData extends Job {
6869
/** @var IConfig */
6970
private $config;
7071

71-
/**
72-
* VerifyUserData constructor.
73-
*
74-
* @param AccountManager $accountManager
75-
* @param IUserManager $userManager
76-
* @param IClientService $clientService
77-
* @param ILogger $logger
78-
* @param IConfig $config
79-
*/
8072
public function __construct(AccountManager $accountManager,
8173
IUserManager $userManager,
8274
IClientService $clientService,
8375
ILogger $logger,
76+
ITimeFactory $timeFactory,
8477
IConfig $config
8578
) {
79+
parent::__construct($timeFactory);
8680
$this->accountManager = $accountManager;
8781
$this->userManager = $userManager;
8882
$this->httpClientService = $clientService;

0 commit comments

Comments
 (0)