aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/Command/Background/JobBase.php10
-rw-r--r--core/Command/Background/JobWorker.php5
-rw-r--r--core/register_command.php5
-rw-r--r--lib/private/BackgroundJob/JobList.php5
-rw-r--r--lib/public/BackgroundJob/IJobList.php12
5 files changed, 24 insertions, 13 deletions
diff --git a/core/Command/Background/JobBase.php b/core/Command/Background/JobBase.php
index fe2880c0988..4385783a7ee 100644
--- a/core/Command/Background/JobBase.php
+++ b/core/Command/Background/JobBase.php
@@ -45,6 +45,10 @@ abstract class JobBase extends \OC\Core\Command\Base {
protected function printJobInfo(int $jobId, IJob $job, OutputInterface $output): void {
$row = $this->jobList->getDetailsById($jobId);
+ if ($row === null) {
+ return;
+ }
+
$lastRun = new \DateTime();
$lastRun->setTimestamp((int) $row['last_run']);
$lastChecked = new \DateTime();
@@ -55,10 +59,10 @@ abstract class JobBase extends \OC\Core\Command\Base {
$output->writeln('Job class: ' . get_class($job));
$output->writeln('Arguments: ' . json_encode($job->getArgument()));
- $isTimedJob = $job instanceof \OC\BackgroundJob\TimedJob || $job instanceof \OCP\BackgroundJob\TimedJob;
+ $isTimedJob = $job instanceof \OCP\BackgroundJob\TimedJob;
if ($isTimedJob) {
$output->writeln('Type: timed');
- } elseif ($job instanceof \OC\BackgroundJob\QueuedJob || $job instanceof \OCP\BackgroundJob\QueuedJob) {
+ } elseif ($job instanceof \OCP\BackgroundJob\QueuedJob) {
$output->writeln('Type: queued');
} else {
$output->writeln('Type: job');
@@ -81,7 +85,7 @@ abstract class JobBase extends \OC\Core\Command\Base {
$interval = $intervalProperty->getValue($job);
$nextRun = new \DateTime();
- $nextRun->setTimestamp($row['last_run'] + $interval);
+ $nextRun->setTimestamp((int)$row['last_run'] + $interval);
if ($nextRun > new \DateTime()) {
$output->writeln('Next execution: <comment>' . $nextRun->format(\DateTimeInterface::ATOM) . '</comment>');
diff --git a/core/Command/Background/JobWorker.php b/core/Command/Background/JobWorker.php
index aa991c96137..8fb7ed139f6 100644
--- a/core/Command/Background/JobWorker.php
+++ b/core/Command/Background/JobWorker.php
@@ -27,6 +27,7 @@ namespace OC\Core\Command\Background;
use OC\Core\Command\InterruptedException;
use OCP\BackgroundJob\IJobList;
+use OCP\ITempManager;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@@ -101,11 +102,11 @@ class JobWorker extends JobBase {
$this->printJobInfo($job->getId(), $job, $output);
}
- $job->execute($this->jobList, \OC::$server->getLogger());
+ $job->start($this->jobList);
// clean up after unclean jobs
\OC_Util::tearDownFS();
- \OC::$server->getTempManager()->clean();
+ \OC::$server->get(ITempManager::class)->clean();
$this->jobList->setLastJob($job);
$this->jobList->unlockJob($job);
diff --git a/core/register_command.php b/core/register_command.php
index f3ae8efa300..88ece906846 100644
--- a/core/register_command.php
+++ b/core/register_command.php
@@ -55,11 +55,6 @@ use OCP\IConfig;
use OCP\Server;
use Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand;
-use OC\Core\Command;
-use OCP\IConfig;
-use OCP\Server;
-use Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand;
-
$application->add(new CompletionCommand());
$application->add(Server::get(Command\Status::class));
$application->add(Server::get(Command\Check::class));
diff --git a/lib/private/BackgroundJob/JobList.php b/lib/private/BackgroundJob/JobList.php
index 36f46d7bad7..9d54fa45bfc 100644
--- a/lib/private/BackgroundJob/JobList.php
+++ b/lib/private/BackgroundJob/JobList.php
@@ -448,11 +448,14 @@ class JobList implements IJobList {
$result = $query->executeQuery();
$jobs = [];
+
while (($row = $result->fetch()) !== false) {
+ /**
+ * @var array{count:int, class:class-string} $row
+ */
$jobs[] = $row;
}
return $jobs;
-
}
}
diff --git a/lib/public/BackgroundJob/IJobList.php b/lib/public/BackgroundJob/IJobList.php
index 07b5ebcf48b..e2e9eca9415 100644
--- a/lib/public/BackgroundJob/IJobList.php
+++ b/lib/public/BackgroundJob/IJobList.php
@@ -110,9 +110,9 @@ interface IJobList {
/**
* get the next job in the list
*
- * @since 7.0.0 - In 24.0.0 parameter $onlyTimeSensitive got added
+ * @since 7.0.0 - In 24.0.0 parameter $onlyTimeSensitive got added; In 29.0.0 parameter $jobClass got added
*/
- public function getNext(bool $onlyTimeSensitive = false): ?IJob;
+ public function getNext(bool $onlyTimeSensitive = false, string $jobClass = null): ?IJob;
/**
* @since 7.0.0
@@ -168,4 +168,12 @@ interface IJobList {
* @since 27.0.0
*/
public function hasReservedJob(?string $className): bool;
+
+ /**
+ * Returns a count of jobs per Job class
+ *
+ * @return list<array{class:class-string, count:int}>
+ * @since 29.0.0
+ */
+ public function countByClass(): array;
}