aboutsummaryrefslogtreecommitdiffstats
path: root/core/Command
diff options
context:
space:
mode:
authorJulien Veyssier <julien-nc@posteo.net>2024-04-11 10:55:39 +0200
committerJulien Veyssier <julien-nc@posteo.net>2024-05-02 16:43:42 +0200
commit0eb4cddc54c3b499c901bdd806b7b2aaeb5060e2 (patch)
tree13173812489014f7974dd6da9e30f1bdeb526d4a /core/Command
parentd967151f520ba6c860ed9a727e3363ec04a6506d (diff)
downloadnextcloud-server-0eb4cddc54c3b499c901bdd806b7b2aaeb5060e2.tar.gz
nextcloud-server-0eb4cddc54c3b499c901bdd806b7b2aaeb5060e2.zip
feat(bg-jobs): support multiple arguments in cron.php and occ:background-job:worker for the job class list
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Diffstat (limited to 'core/Command')
-rw-r--r--core/Command/Background/JobWorker.php28
1 files changed, 7 insertions, 21 deletions
diff --git a/core/Command/Background/JobWorker.php b/core/Command/Background/JobWorker.php
index 0cfe9db940b..0f160e44278 100644
--- a/core/Command/Background/JobWorker.php
+++ b/core/Command/Background/JobWorker.php
@@ -53,8 +53,8 @@ class JobWorker extends JobBase {
->setDescription('Run a background job worker')
->addArgument(
'job-classes',
- InputArgument::OPTIONAL,
- 'The classes of the jobs to look for in the database, comma-separated'
+ InputArgument::OPTIONAL | InputArgument::IS_ARRAY,
+ 'The classes of the jobs to look for in the database'
)
->addOption(
'once',
@@ -73,25 +73,11 @@ class JobWorker extends JobBase {
}
protected function execute(InputInterface $input, OutputInterface $output): int {
- $jobClassesString = $input->getArgument('job-classes');
- // only keep non-empty strings
- $jobClasses = $jobClassesString === null
- ? null
- : array_filter(
- explode(',', $jobClassesString),
- static function (string $jobClass) {
- return strlen($jobClass) > 0;
- }
- );
+ $jobClasses = $input->getArgument('job-classes');
+ $jobClasses = empty($jobClasses) ? null : $jobClasses;
if ($jobClasses !== null) {
- // no class
- if (count($jobClasses) === 0) {
- $output->writeln('<error>Invalid job class list supplied</error>');
- return 1;
- }
-
- // at least one invalid class
+ // at least one class is invalid
foreach ($jobClasses as $jobClass) {
if (!class_exists($jobClass)) {
$output->writeln('<error>Invalid job class: ' . $jobClass . '</error>');
@@ -115,10 +101,10 @@ class JobWorker extends JobBase {
$job = $this->jobList->getNext(false, $jobClasses);
if (!$job) {
if ($input->getOption('once') === true) {
- if ($jobClassesString === null) {
+ if ($jobClasses === null) {
$output->writeln('No job is currently queued', OutputInterface::VERBOSITY_VERBOSE);
} else {
- $output->writeln('No job of classes ' . $jobClassesString . ' is currently queued', OutputInterface::VERBOSITY_VERBOSE);
+ $output->writeln('No job of classes [' . implode(', ', $jobClasses) . '] is currently queued', OutputInterface::VERBOSITY_VERBOSE);
}
$output->writeln('Exiting...', OutputInterface::VERBOSITY_VERBOSE);
break;