Skip to content

Commit

Permalink
fix: Call execute until it is removed for Job class
Browse files Browse the repository at this point in the history
Because if an application extends execute it will change behavior
 without warning otherwise.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
  • Loading branch information
come-nc committed Mar 12, 2024
1 parent 9a52728 commit 75751d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion core/Command/Background/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$output->writeln('<error>Something went wrong when trying to retrieve Job with ID ' . $jobId . ' from database</error>');
return 1;
}
$job->start($this->jobList);
/** Calling execute until it is removed, then will switch to start */
$job->execute($this->jobList);

Check notice

Code scanning / Psalm

DeprecatedMethod Note

The method OCP\BackgroundJob\IJob::execute has been marked as deprecated
$job = $this->jobList->getById($jobId);

if (($job === null) || ($lastRun !== $job->getLastRun())) {
Expand Down
6 changes: 4 additions & 2 deletions cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@
$memoryBefore = memory_get_usage();
$memoryPeakBefore = memory_get_peak_usage();

$job->start($jobList);
/** Calling execute until it is removed, then will switch to start */
$job->execute($jobList);

Check notice

Code scanning / Psalm

DeprecatedMethod Note

The method OCP\BackgroundJob\IJob::execute has been marked as deprecated

$memoryAfter = memory_get_usage();
$memoryPeakAfter = memory_get_peak_usage();
Expand Down Expand Up @@ -207,7 +208,8 @@
$job = $jobList->getNext();
if ($job != null) {
$logger->debug('WebCron call has selected job with ID ' . strval($job->getId()), ['app' => 'cron']);
$job->start($jobList);
/** Calling execute until it is removed, then will switch to start */
$job->execute($jobList);

Check notice

Code scanning / Psalm

DeprecatedMethod Note

The method OCP\BackgroundJob\IJob::execute has been marked as deprecated
$jobList->setLastJob($job);
}
OC_JSON::success();
Expand Down

0 comments on commit 75751d5

Please sign in to comment.