Skip to content

Commit

Permalink
fix: nextcloud#663 error in cron.php since NC 29
Browse files Browse the repository at this point in the history
---
- TimedJob is now OCP, and requires a time
- add modern properties assignment in constructors
---

Signed-off-by: Sebastien Marinier <seb@smarinier.net>
  • Loading branch information
smarinier committed Oct 9, 2024
1 parent 512ae7d commit 3a4a3fe
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 90 deletions.
32 changes: 9 additions & 23 deletions lib/Cron/Backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@

namespace OCA\Backup\Cron;

use OC\BackgroundJob\TimedJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OCA\Backup\Exceptions\JobsTimeSlotException;
use OCA\Backup\Service\ConfigService;
use OCA\Backup\Service\CronService;
Expand All @@ -48,39 +49,24 @@
class Backup extends TimedJob {
use TNCLogger;


/** @var PointService */
private $pointService;

/** @var CronService */
private $cronService;

/** @var ConfigService */
private $configService;

/** @var LoggerInterface */
private $loggerInterface;

/**
* Backup constructor.
*
* @param ITimeFactory $time
* @param PointService $pointService
* @param CronService $cronService
* @param ConfigService $configService
* @param LoggerInterface $loggerInterface
*/
public function __construct(
PointService $pointService,
CronService $cronService,
ConfigService $configService,
LoggerInterface $loggerInterface
ITimeFactory $time,
private PointService $pointService,
private CronService $cronService,
private ConfigService $configService,
private LoggerInterface $loggerInterface
) {
parent::__construct($time);
$this->setInterval(900);

$this->pointService = $pointService;
$this->cronService = $cronService;
$this->configService = $configService;
$this->loggerInterface = $loggerInterface;
}


Expand Down
39 changes: 10 additions & 29 deletions lib/Cron/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@

namespace OCA\Backup\Cron;

use OC\BackgroundJob\TimedJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OCA\Backup\Db\EventRequest;
use OCA\Backup\Model\BackupEvent;
use OCA\Backup\Service\ConfigService;
Expand All @@ -48,46 +49,26 @@
class Event extends TimedJob {
use TArrayTools;


/** @var EventRequest */
private $eventRequest;

/** @var PointService */
private $pointService;

/** @var FilesService */
private $filesService;

/** @var CronService */
private $cronService;

/** @var ConfigService */
private $configService;


/**
* Event constructor.
*
* @param ITimeFactory $time
* @param EventRequest $eventRequest
* @param PointService $pointService
* @param FilesService $filesService
* @param CronService $cronService
* @param ConfigService $configService
*/
public function __construct(
EventRequest $eventRequest,
PointService $pointService,
FilesService $filesService,
CronService $cronService,
ConfigService $configService
ITimeFactory $time,
private EventRequest $eventRequest,
private PointService $pointService,
private FilesService $filesService,
private CronService $cronService,
private ConfigService $configService
) {
parent::__construct($time);
$this->setInterval(1);

$this->eventRequest = $eventRequest;
$this->pointService = $pointService;
$this->filesService = $filesService;
$this->cronService = $cronService;
$this->configService = $configService;
}


Expand Down
50 changes: 12 additions & 38 deletions lib/Cron/Manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@

namespace OCA\Backup\Cron;

use OC\BackgroundJob\TimedJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OCA\Backup\Exceptions\ExternalFolderNotFoundException;
use OCA\Backup\Exceptions\JobsTimeSlotException;
use OCA\Backup\Model\RestoringPoint;
Expand All @@ -52,31 +53,10 @@
class Manage extends TimedJob {
public const DELAY_CHECK_HEALTH = 86400 * 7; // 7d

/** @var CronService */
private $cronService;

/** @var PointService */
private $pointService;

/** @var PackService */
private $packService;

/** @var UploadService */
private $uploadService;

/** @var ExternalFolderService */
private $externalFolderService;

/** @var OutputService */
private $outputService;

/** @var ConfigService */
private $configService;


/**
* Manage constructor.
*
* @param ITimeFactory $time
* @param CronService $cronService
* @param PointService $pointService
* @param PackService $packService
Expand All @@ -86,23 +66,17 @@ class Manage extends TimedJob {
* @param ConfigService $configService
*/
public function __construct(
CronService $cronService,
PointService $pointService,
PackService $packService,
UploadService $uploadService,
ExternalFolderService $externalFolderService,
OutputService $outputService,
ConfigService $configService
ITimeFactory $time,
private CronService $cronService,
private PointService $pointService,
private PackService $packService,
private UploadService $uploadService,
private ExternalFolderService $externalFolderService,
private OutputService $outputService,
private ConfigService $configService
) {
parent::__construct($time);
$this->setInterval(3600);

$this->cronService = $cronService;
$this->pointService = $pointService;
$this->packService = $packService;
$this->uploadService = $uploadService;
$this->externalFolderService = $externalFolderService;
$this->outputService = $outputService;
$this->configService = $configService;
}


Expand Down

0 comments on commit 3a4a3fe

Please sign in to comment.