From ca8602c50432259f09cb5d5fcbe31760266d93a0 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Fri, 2 Feb 2024 08:24:42 -0800 Subject: [PATCH] --job-id option --- CHANGELOG-WIP.md | 3 +++ src/queue/Command.php | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/CHANGELOG-WIP.md b/CHANGELOG-WIP.md index 858a458ccb1..d05705b02bb 100644 --- a/CHANGELOG-WIP.md +++ b/CHANGELOG-WIP.md @@ -1 +1,4 @@ # Release notes for Craft CMS 4.8.0 (WIP) + +### Administration +- The `queue/run` command now supports a `--job-id` option. diff --git a/src/queue/Command.php b/src/queue/Command.php index d350b42b2fb..32c255eb254 100644 --- a/src/queue/Command.php +++ b/src/queue/Command.php @@ -23,6 +23,12 @@ class Command extends \yii\queue\cli\Command { use ControllerTrait; + /** + * @var string The job ID to run + * @since 4.8.0 + */ + public ?string $jobId = null; + /** * @var Queue */ @@ -40,6 +46,18 @@ class Command extends \yii\queue\cli\Command 'class' => VerboseBehavior::class, ]; + /** + * @inheritdoc + */ + public function options($actionID) + { + $options = parent::options($actionID); + if ($actionID === 'run') { + $options[] = 'jobId'; + } + return $options; + } + /** * @inheritdoc */ @@ -65,6 +83,10 @@ public function actions(): array */ public function actionRun(): int { + if ($this->jobId) { + return $this->queue->executeJob($this->jobId) ? ExitCode::OK : ExitCode::UNSPECIFIED_ERROR; + } + return $this->queue->run() ?? ExitCode::OK; }