chore: Remove deprecated `IJob::execute` method

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
pull/48197/head
Ferdinand Thiessen 1 year ago
parent ccff168960
commit 89896b1d89
No known key found for this signature in database
GPG Key ID: 45FAE7268762B400
  1. 3
      core/Command/Background/Job.php
  2. 4
      core/Command/Background/JobWorker.php
  3. 6
      cron.php
  4. 17
      lib/public/BackgroundJob/IJob.php
  5. 24
      lib/public/BackgroundJob/Job.php
  6. 17
      lib/public/BackgroundJob/QueuedJob.php
  7. 18
      lib/public/BackgroundJob/TimedJob.php

@ -69,8 +69,7 @@ class Job extends Command {
$output->writeln('<error>Something went wrong when trying to retrieve Job with ID ' . $jobId . ' from database</error>'); $output->writeln('<error>Something went wrong when trying to retrieve Job with ID ' . $jobId . ' from database</error>');
return 1; return 1;
} }
/** @psalm-suppress DeprecatedMethod Calling execute until it is removed, then will switch to start */ $job->start($this->jobList);
$job->execute($this->jobList);
$job = $this->jobList->getById($jobId); $job = $this->jobList->getById($jobId);
if (($job === null) || ($lastRun !== $job->getLastRun())) { if (($job === null) || ($lastRun !== $job->getLastRun())) {

@ -125,9 +125,7 @@ class JobWorker extends JobBase {
$this->printJobInfo($job->getId(), $job, $output); $this->printJobInfo($job->getId(), $job, $output);
} }
/** @psalm-suppress DeprecatedMethod Calling execute until it is removed, then will switch to start */ $job->start($this->jobList);
$job->execute($this->jobList);
$output->writeln('Job ' . $job->getId() . ' has finished', OutputInterface::VERBOSITY_VERBOSE); $output->writeln('Job ' . $job->getId() . ' has finished', OutputInterface::VERBOSITY_VERBOSE);
// clean up after unclean jobs // clean up after unclean jobs

@ -171,8 +171,7 @@ Options:
echo 'Starting job ' . $jobDetails . PHP_EOL; echo 'Starting job ' . $jobDetails . PHP_EOL;
} }
/** @psalm-suppress DeprecatedMethod Calling execute until it is removed, then will switch to start */ $job->start($jobList);
$job->execute($jobList);
$timeAfter = time(); $timeAfter = time();
$memoryAfter = memory_get_usage(); $memoryAfter = memory_get_usage();
@ -237,8 +236,7 @@ Options:
$job = $jobList->getNext(); $job = $jobList->getNext();
if ($job != null) { if ($job != null) {
$logger->debug('WebCron call has selected job with ID ' . strval($job->getId()), ['app' => 'cron']); $logger->debug('WebCron call has selected job with ID ' . strval($job->getId()), ['app' => 'cron']);
/** @psalm-suppress DeprecatedMethod Calling execute until it is removed, then will switch to start */ $job->start($jobList);
$job->execute($jobList);
$jobList->setLastJob($job); $jobList->setLastJob($job);
} }
OC_JSON::success(); OC_JSON::success();

@ -7,8 +7,6 @@
*/ */
namespace OCP\BackgroundJob; namespace OCP\BackgroundJob;
use OCP\ILogger;
/** /**
* This interface represents a background job run with cron * This interface represents a background job run with cron
* *
@ -16,6 +14,8 @@ use OCP\ILogger;
* \OCP\BackgroundJob\TimedJob or \OCP\BackgroundJob\QueuedJob * \OCP\BackgroundJob\TimedJob or \OCP\BackgroundJob\QueuedJob
* *
* @since 7.0.0 * @since 7.0.0
* @since 25.0.0 deprecated `execute()` method in favor of `start()`
* @since 33.0.0 removed deprecated `execute()` method
*/ */
interface IJob { interface IJob {
/** /**
@ -27,17 +27,6 @@ interface IJob {
*/ */
public const TIME_SENSITIVE = 1; public const TIME_SENSITIVE = 1;
/**
* Run the background job with the registered argument
*
* @param IJobList $jobList The job list that manages the state of this job
* @param ILogger|null $logger
* @since 7.0.0
* @deprecated 25.0.0 Use start() instead. This method will be removed
* with the ILogger interface
*/
public function execute(IJobList $jobList, ?ILogger $logger = null);
/** /**
* Start the background job with the registered argument * Start the background job with the registered argument
* *
@ -45,7 +34,7 @@ interface IJob {
* the state and cleaning up the job list after running the job. * the state and cleaning up the job list after running the job.
* *
* For common background job scenario, you will want to use TimedJob or QueuedJob * For common background job scenario, you will want to use TimedJob or QueuedJob
* instead of overwritting this method. * instead of overwriting this method.
* *
* @param IJobList $jobList The job list that manages the state of this job * @param IJobList $jobList The job list that manages the state of this job
* @since 25.0.0 * @since 25.0.0

@ -8,7 +8,6 @@ declare(strict_types=1);
namespace OCP\BackgroundJob; namespace OCP\BackgroundJob;
use OCP\AppFramework\Utility\ITimeFactory; use OCP\AppFramework\Utility\ITimeFactory;
use OCP\ILogger;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
/** /**
@ -18,32 +17,21 @@ use Psr\Log\LoggerInterface;
* For the most common use cases have a look at QueuedJob and TimedJob * For the most common use cases have a look at QueuedJob and TimedJob
* *
* @since 15.0.0 * @since 15.0.0
* @since 25.0.0 deprecated `execute()` method in favor of `start()`
* @since 33.0.0 removed deprecated `execute()` method
*/ */
abstract class Job implements IJob, IParallelAwareJob { abstract class Job implements IJob, IParallelAwareJob {
protected int $id = 0; protected int $id = 0;
protected int $lastRun = 0; protected int $lastRun = 0;
protected $argument; protected mixed $argument = null;
protected ITimeFactory $time;
protected bool $allowParallelRuns = true; protected bool $allowParallelRuns = true;
/** /**
* @since 15.0.0 * @since 15.0.0
*/ */
public function __construct(ITimeFactory $time) { public function __construct(
$this->time = $time; protected ITimeFactory $time,
} ) {
/**
* The function to prepare the execution of the job.
*
* @return void
*
* @since 15.0.0
* @deprecated 25.0.0 Use start() instead. This method will be removed
* with the ILogger interface
*/
public function execute(IJobList $jobList, ?ILogger $logger = null) {
$this->start($jobList);
} }
/** /**

@ -7,27 +7,14 @@ declare(strict_types=1);
*/ */
namespace OCP\BackgroundJob; namespace OCP\BackgroundJob;
use OCP\ILogger;
/** /**
* Simple base class for a one time background job * Simple base class for a one time background job
* *
* @since 15.0.0 * @since 15.0.0
* @since 25.0.0 deprecated `execute()` method in favor of `start()`
* @since 33.0.0 removed deprecated `execute()` method
*/ */
abstract class QueuedJob extends Job { abstract class QueuedJob extends Job {
/**
* Run the job, then remove it from the joblist
*
* @param IJobList $jobList
* @param ILogger|null $logger
*
* @since 15.0.0
* @deprecated 25.0.0 Use start() instead. This method will be removed
* with the ILogger interface
*/
final public function execute($jobList, ?ILogger $logger = null) {
$this->start($jobList);
}
/** /**
* Run the job, then remove it from the joblist * Run the job, then remove it from the joblist

@ -7,7 +7,6 @@ declare(strict_types=1);
*/ */
namespace OCP\BackgroundJob; namespace OCP\BackgroundJob;
use OCP\ILogger;
use OCP\Server; use OCP\Server;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
@ -16,6 +15,8 @@ use Psr\Log\LoggerInterface;
* Call setInterval with your desired interval in seconds from the constructor. * Call setInterval with your desired interval in seconds from the constructor.
* *
* @since 15.0.0 * @since 15.0.0
* @since 25.0.0 deprecated `execute()` method in favor of `start()`
* @since 33.0.0 removed deprecated `execute()` method
*/ */
abstract class TimedJob extends Job { abstract class TimedJob extends Job {
protected int $interval = 0; protected int $interval = 0;
@ -28,7 +29,7 @@ abstract class TimedJob extends Job {
* *
* @since 15.0.0 * @since 15.0.0
*/ */
public function setInterval(int $seconds) { public function setInterval(int $seconds): void {
$this->interval = $seconds; $this->interval = $seconds;
} }
@ -71,19 +72,6 @@ abstract class TimedJob extends Job {
$this->timeSensitivity = $sensitivity; $this->timeSensitivity = $sensitivity;
} }
/**
* Run the job if the last run is more than the interval ago
*
* @param IJobList $jobList
* @param ILogger|null $logger
*
* @since 15.0.0
* @deprecated 25.0.0 Use start() instead
*/
final public function execute(IJobList $jobList, ?ILogger $logger = null) {
$this->start($jobList);
}
/** /**
* Run the job if the last run is more than the interval ago * Run the job if the last run is more than the interval ago
* *

Loading…
Cancel
Save