Skip to content

Commit a0f6a65

Browse files
committed
Use TimedJob from OCP instead of OC
Signed-off-by: Côme Chilliet <[email protected]>
1 parent 944be79 commit a0f6a65

File tree

10 files changed

+57
-28
lines changed

10 files changed

+57
-28
lines changed

apps/admin_audit/lib/BackgroundJobs/Rotate.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
*/
2828
namespace OCA\AdminAudit\BackgroundJobs;
2929

30-
use OC\BackgroundJob\TimedJob;
30+
use OCP\BackgroundJob\TimedJob;
31+
use OCP\AppFramework\Utility\ITimeFactory;
3132
use OCP\IConfig;
3233
use OCP\Log\RotationTrait;
3334

@@ -37,13 +38,16 @@ class Rotate extends TimedJob {
3738
/** @var IConfig */
3839
private $config;
3940

40-
public function __construct(IConfig $config) {
41+
public function __construct(ITimeFactory $time,
42+
IConfig $config) {
43+
parent::__construct($time);
44+
4145
$this->config = $config;
4246

4347
$this->setInterval(60 * 60 * 3);
4448
}
4549

46-
protected function run($argument) {
50+
protected function run($argument): void {
4751
$default = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log';
4852
$this->filePath = $this->config->getAppValue('admin_audit', 'logfile', $default);
4953

apps/files/lib/BackgroundJob/CleanupDirectEditingTokens.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
declare(strict_types=1);
4+
25
/**
36
* @copyright Copyright (c) 2016 Julius Härtl <[email protected]>
47
*
@@ -23,18 +26,18 @@
2326
*/
2427
namespace OCA\Files\BackgroundJob;
2528

26-
use OC\BackgroundJob\TimedJob;
29+
use OCP\AppFramework\Utility\ITimeFactory;
30+
use OCP\BackgroundJob\TimedJob;
2731
use OCP\DirectEditing\IManager;
2832

2933
class CleanupDirectEditingTokens extends TimedJob {
3034
private const INTERVAL_MINUTES = 15 * 60;
3135

32-
/**
33-
* @var IManager
34-
*/
35-
private $manager;
36+
private IManager $manager;
3637

37-
public function __construct(IManager $manager) {
38+
public function __construct(ITimeFactory $time,
39+
IManager $manager) {
40+
parent::__construct($time);
3841
$this->interval = self::INTERVAL_MINUTES;
3942
$this->manager = $manager;
4043
}

apps/files/lib/BackgroundJob/CleanupFileLocks.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
*/
2424
namespace OCA\Files\BackgroundJob;
2525

26-
use OC\BackgroundJob\TimedJob;
26+
use OCP\AppFramework\Utility\ITimeFactory;
27+
use OCP\BackgroundJob\TimedJob;
2728
use OC\Lock\DBLockingProvider;
2829

2930
/**
3031
* Clean up all file locks that are expired for the DB file locking provider
3132
*/
3233
class CleanupFileLocks extends TimedJob {
33-
3434
/**
3535
* Default interval in minutes
3636
*
@@ -41,7 +41,9 @@ class CleanupFileLocks extends TimedJob {
4141
/**
4242
* sets the correct interval for this timed job
4343
*/
44-
public function __construct() {
44+
public function __construct(ITimeFactory $time) {
45+
parent::__construct($time);
46+
4547
$this->interval = $this->defaultIntervalMin * 60;
4648
}
4749

apps/files/lib/BackgroundJob/DeleteOrphanedItems.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
*/
2525
namespace OCA\Files\BackgroundJob;
2626

27-
use OC\BackgroundJob\TimedJob;
27+
use OCP\AppFramework\Utility\ITimeFactory;
28+
use OCP\BackgroundJob\TimedJob;
2829
use OCP\DB\QueryBuilder\IQueryBuilder;
2930

3031
/**
@@ -49,7 +50,8 @@ class DeleteOrphanedItems extends TimedJob {
4950
/**
5051
* sets the correct interval for this timed job
5152
*/
52-
public function __construct() {
53+
public function __construct(ITimeFactory $time) {
54+
parent::__construct($time);
5355
$this->interval = $this->defaultIntervalMin * 60;
5456
$this->connection = \OC::$server->getDatabaseConnection();
5557
$this->logger = \OC::$server->getLogger();

apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
*/
2727
namespace OCA\Files_Sharing\BackgroundJob;
2828

29-
use OC\BackgroundJob\TimedJob;
29+
use OCP\AppFramework\Utility\ITimeFactory;
30+
use OCP\BackgroundJob\TimedJob;
3031
use OCP\IDBConnection;
3132
use OCP\OCS\IDiscoveryService;
3233

@@ -36,8 +37,10 @@ class FederatedSharesDiscoverJob extends TimedJob {
3637
/** @var IDiscoveryService */
3738
private $discoveryService;
3839

39-
public function __construct(IDBConnection $connection,
40+
public function __construct(ITimeFactory $time,
41+
IDBConnection $connection,
4042
IDiscoveryService $discoveryService) {
43+
parent::__construct($time);
4144
$this->connection = $connection;
4245
$this->discoveryService = $discoveryService;
4346

apps/files_sharing/lib/DeleteOrphanedSharesJob.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
*/
2525
namespace OCA\Files_Sharing;
2626

27-
use OC\BackgroundJob\TimedJob;
27+
use OCP\AppFramework\Utility\ITimeFactory;
28+
use OCP\BackgroundJob\TimedJob;
2829

2930
/**
3031
* Delete all share entries that have no matching entries in the file cache table.
3132
*/
3233
class DeleteOrphanedSharesJob extends TimedJob {
33-
3434
/**
3535
* Default interval in minutes
3636
*
@@ -41,7 +41,9 @@ class DeleteOrphanedSharesJob extends TimedJob {
4141
/**
4242
* sets the correct interval for this timed job
4343
*/
44-
public function __construct() {
44+
public function __construct(ITimeFactory $time) {
45+
parent::__construct($time);
46+
4547
$this->interval = $this->defaultIntervalMin * 60;
4648
}
4749

apps/updatenotification/lib/Notification/BackgroundJob.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@
2626
*/
2727
namespace OCA\UpdateNotification\Notification;
2828

29-
use OC\BackgroundJob\TimedJob;
3029
use OC\Installer;
3130
use OC\Updater\VersionCheck;
3231
use OCP\App\IAppManager;
32+
use OCP\AppFramework\Utility\ITimeFactory;
33+
use OCP\BackgroundJob\TimedJob;
3334
use OCP\Http\Client\IClientService;
3435
use OCP\IConfig;
3536
use OCP\IGroup;
@@ -60,12 +61,14 @@ class BackgroundJob extends TimedJob {
6061
/** @var string[] */
6162
protected $users;
6263

63-
public function __construct(IConfig $config,
64+
public function __construct(ITimeFactory $timeFactory,
65+
IConfig $config,
6466
IManager $notificationManager,
6567
IGroupManager $groupManager,
6668
IAppManager $appManager,
6769
IClientService $client,
6870
Installer $installer) {
71+
parent::__construct($timeFactory);
6972
// Run once a day
7073
$this->setInterval(60 * 60 * 24);
7174

apps/user_ldap/lib/Jobs/CleanUp.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
*/
2626
namespace OCA\User_LDAP\Jobs;
2727

28-
use OC\BackgroundJob\TimedJob;
28+
use OCP\AppFramework\Utility\ITimeFactory;
29+
use OCP\BackgroundJob\TimedJob;
2930
use OCA\User_LDAP\Helper;
3031
use OCA\User_LDAP\Mapping\UserMapping;
3132
use OCA\User_LDAP\User\DeletedUsersIndex;
@@ -64,7 +65,12 @@ class CleanUp extends TimedJob {
6465
/** @var DeletedUsersIndex */
6566
protected $dui;
6667

67-
public function __construct(User_Proxy $userBackend, DeletedUsersIndex $dui) {
68+
public function __construct(
69+
ITimeFactory $timeFactory,
70+
User_Proxy $userBackend,
71+
DeletedUsersIndex $dui
72+
) {
73+
parent::__construct($timeFactory);
6874
$minutes = \OC::$server->getConfig()->getSystemValue(
6975
'ldapUserCleanupInterval', (string)$this->defaultIntervalMin);
7076
$this->setInterval((int)$minutes * 60);

apps/workflowengine/lib/BackgroundJobs/Rotate.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@
2323
*/
2424
namespace OCA\WorkflowEngine\BackgroundJobs;
2525

26-
use OC\BackgroundJob\TimedJob;
26+
use OCP\AppFramework\Utility\ITimeFactory;
27+
use OCP\BackgroundJob\TimedJob;
2728
use OCA\WorkflowEngine\AppInfo\Application;
2829
use OCP\Log\RotationTrait;
2930

3031
class Rotate extends TimedJob {
3132
use RotationTrait;
3233

33-
public function __construct() {
34+
public function __construct(ITimeFactory $time) {
35+
parent::__construct($time);
3436
$this->setInterval(60 * 60 * 3);
3537
}
3638

lib/private/Preview/BackgroundCleanupJob.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@
2525
*/
2626
namespace OC\Preview;
2727

28-
use OC\BackgroundJob\TimedJob;
2928
use OC\Preview\Storage\Root;
29+
use OCP\AppFramework\Utility\ITimeFactory;
30+
use OCP\BackgroundJob\TimedJob;
3031
use OCP\DB\QueryBuilder\IQueryBuilder;
3132
use OCP\Files\IMimeTypeLoader;
3233
use OCP\Files\NotFoundException;
3334
use OCP\Files\NotPermittedException;
3435
use OCP\IDBConnection;
3536

3637
class BackgroundCleanupJob extends TimedJob {
37-
3838
/** @var IDBConnection */
3939
private $connection;
4040

@@ -47,10 +47,12 @@ class BackgroundCleanupJob extends TimedJob {
4747
/** @var IMimeTypeLoader */
4848
private $mimeTypeLoader;
4949

50-
public function __construct(IDBConnection $connection,
50+
public function __construct(ITimeFactory $timeFactory,
51+
IDBConnection $connection,
5152
Root $previewFolder,
5253
IMimeTypeLoader $mimeTypeLoader,
5354
bool $isCLI) {
55+
parent::__construct($timeFactory);
5456
// Run at most once an hour
5557
$this->setInterval(3600);
5658

0 commit comments

Comments
 (0)