diff --git a/core/Command/Background/JobWorker.php b/core/Command/Background/JobWorker.php
index 0cfe9db940b10..0f160e442787a 100644
--- a/core/Command/Background/JobWorker.php
+++ b/core/Command/Background/JobWorker.php
@@ -53,8 +53,8 @@ protected function configure(): void {
->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 @@ protected function configure(): void {
}
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('Invalid job class list supplied');
- return 1;
- }
-
- // at least one invalid class
+ // at least one class is invalid
foreach ($jobClasses as $jobClass) {
if (!class_exists($jobClass)) {
$output->writeln('Invalid job class: ' . $jobClass . '');
@@ -115,10 +101,10 @@ static function (string $jobClass) {
$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;
diff --git a/cron.php b/cron.php
index d0a8b770dfc82..9b0489653efd0 100644
--- a/cron.php
+++ b/cron.php
@@ -62,10 +62,10 @@
Run the background job routine
Usage:
- php -f cron.php -- [-h] []
+ php -f cron.php -- [-h] [...]
Arguments:
- job-classes Optional job class comma-separated list to only run those jobs
+ job-classes Optional job class list to only run those jobs
Options:
-h, --help Display this help message' . PHP_EOL;
@@ -175,16 +175,10 @@
$endTime = time() + 14 * 60;
$executedJobs = [];
- // a specific job class list can optionally be given as first argument
- // only keep non-empty strings
- $jobClasses = isset($argv[1])
- ? array_filter(
- explode(',', $argv[1]),
- static function (string $jobClass) {
- return strlen($jobClass) > 0;
- }
- )
- : null;
+ // a specific job class list can optionally be given as argument
+ $jobClasses = array_slice($argv, 1);
+ $jobClasses = empty($jobClasses) ? null : $jobClasses;
+
while ($job = $jobList->getNext($onlyTimeSensitive, $jobClasses)) {
if (isset($executedJobs[$job->getId()])) {
$jobList->unlockJob($job);