aboutsummaryrefslogtreecommitdiffstats
path: root/core/Command/Background
diff options
context:
space:
mode:
Diffstat (limited to 'core/Command/Background')
-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;