From e551c94ac504fea20fe1eb928dfccad8a8d1abdd Mon Sep 17 00:00:00 2001 From: Lito Date: Thu, 23 Jul 2020 16:23:16 +0200 Subject: [PATCH 1/2] Added range option to queue:retry command --- src/Illuminate/Queue/Console/RetryCommand.php | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Queue/Console/RetryCommand.php b/src/Illuminate/Queue/Console/RetryCommand.php index c218ed48f98b..6a25f925dc34 100644 --- a/src/Illuminate/Queue/Console/RetryCommand.php +++ b/src/Illuminate/Queue/Console/RetryCommand.php @@ -12,7 +12,9 @@ class RetryCommand extends Command * * @var string */ - protected $signature = 'queue:retry {id* : The ID of the failed job or "all" to retry all jobs}'; + protected $signature = 'queue:retry + {id?* : The ID of the failed job or "all" to retry all jobs} + {--range=* : Range of ids (only numeric are allowed) to be retried}'; /** * The console command description. @@ -53,7 +55,30 @@ protected function getJobIds() $ids = (array) $this->argument('id'); if (count($ids) === 1 && $ids[0] === 'all') { - $ids = Arr::pluck($this->laravel['queue.failer']->all(), 'id'); + return Arr::pluck($this->laravel['queue.failer']->all(), 'id'); + } + + if ($ranges = (array) $this->option('range')) { + $ids = array_merge($ids, $this->getJobIdsByRanges($ranges)); + } + + return array_values(array_filter(array_unique($ids))); + } + + /** + * Get the job IDs from range option. + * + * @param array $ranges + * @return array + */ + protected function getJobIdsByRanges(array $ranges) + { + $ids = []; + + foreach ($ranges as $range) { + if (preg_match('/^[0-9]+\-[0-9]+$/', $range)) { + $ids = array_merge($ids, range(...explode('-', $range))); + } } return $ids; From 1279d15369aa040acf5767e539a7c57eee5f5690 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 23 Jul 2020 13:18:21 -0500 Subject: [PATCH 2/2] Update RetryCommand.php --- src/Illuminate/Queue/Console/RetryCommand.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Queue/Console/RetryCommand.php b/src/Illuminate/Queue/Console/RetryCommand.php index 6a25f925dc34..e9120a976962 100644 --- a/src/Illuminate/Queue/Console/RetryCommand.php +++ b/src/Illuminate/Queue/Console/RetryCommand.php @@ -14,7 +14,7 @@ class RetryCommand extends Command */ protected $signature = 'queue:retry {id?* : The ID of the failed job or "all" to retry all jobs} - {--range=* : Range of ids (only numeric are allowed) to be retried}'; + {--range=* : Range of job IDs (numeric) to be retried}'; /** * The console command description. @@ -66,9 +66,9 @@ protected function getJobIds() } /** - * Get the job IDs from range option. + * Get the job IDs ranges, if applicable. * - * @param array $ranges + * @param array $ranges * @return array */ protected function getJobIdsByRanges(array $ranges)