From 7aca65833887d0760fc61e320bc46b80c9cb3398 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 16 Jun 2021 07:26:34 -0500 Subject: [PATCH] formatting --- .../Providers/ArtisanServiceProvider.php | 2 +- .../Queue/Console/PruneFailedJobsCommand.php | 6 ++++- .../Failed/DatabaseFailedJobProvider.php | 23 +++++++++---------- .../Failed/DatabaseUuidFailedJobProvider.php | 23 +++++++++---------- 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php index ab8078a191b5..5728f23c1f58 100755 --- a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php +++ b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php @@ -708,7 +708,7 @@ protected function registerQueuePruneBatchesCommand() protected function registerQueuePruneFailedJobsCommand() { $this->app->singleton('command.queue.prune-failed-jobs', function () { - return new PruneFailedJobsCommand(); + return new PruneFailedJobsCommand; }); } diff --git a/src/Illuminate/Queue/Console/PruneFailedJobsCommand.php b/src/Illuminate/Queue/Console/PruneFailedJobsCommand.php index d613d63561f4..f82d9be3b955 100644 --- a/src/Illuminate/Queue/Console/PruneFailedJobsCommand.php +++ b/src/Illuminate/Queue/Console/PruneFailedJobsCommand.php @@ -26,7 +26,7 @@ class PruneFailedJobsCommand extends Command /** * Execute the console command. * - * @return void + * @return int|null */ public function handle() { @@ -36,6 +36,10 @@ public function handle() if ($failer instanceof PrunableFailedJobProvider) { $count = $failer->prune(Carbon::now()->subHours($this->option('hours'))); + } else { + $this->error('The ['.class_basename($failer).'] failed job storage driver does not support pruning.'); + + return 1; } $this->info("{$count} entries deleted!"); diff --git a/src/Illuminate/Queue/Failed/DatabaseFailedJobProvider.php b/src/Illuminate/Queue/Failed/DatabaseFailedJobProvider.php index 7eeacba6ed94..a4d98e03277a 100644 --- a/src/Illuminate/Queue/Failed/DatabaseFailedJobProvider.php +++ b/src/Illuminate/Queue/Failed/DatabaseFailedJobProvider.php @@ -106,16 +106,6 @@ public function flush() $this->getTable()->delete(); } - /** - * Get a new query builder instance for the table. - * - * @return \Illuminate\Database\Query\Builder - */ - protected function getTable() - { - return $this->resolver->connection($this->database)->table($this->table); - } - /** * Prune all of the entries older than the given date. * @@ -124,8 +114,7 @@ protected function getTable() */ public function prune(DateTimeInterface $before) { - $query = $this->getTable() - ->where('failed_at', '<', $before); + $query = $this->getTable()->where('failed_at', '<', $before); $totalDeleted = 0; @@ -137,4 +126,14 @@ public function prune(DateTimeInterface $before) return $totalDeleted; } + + /** + * Get a new query builder instance for the table. + * + * @return \Illuminate\Database\Query\Builder + */ + protected function getTable() + { + return $this->resolver->connection($this->database)->table($this->table); + } } diff --git a/src/Illuminate/Queue/Failed/DatabaseUuidFailedJobProvider.php b/src/Illuminate/Queue/Failed/DatabaseUuidFailedJobProvider.php index 90b2d0ced86d..cf9548bb31fe 100644 --- a/src/Illuminate/Queue/Failed/DatabaseUuidFailedJobProvider.php +++ b/src/Illuminate/Queue/Failed/DatabaseUuidFailedJobProvider.php @@ -119,16 +119,6 @@ public function flush() $this->getTable()->delete(); } - /** - * Get a new query builder instance for the table. - * - * @return \Illuminate\Database\Query\Builder - */ - protected function getTable() - { - return $this->resolver->connection($this->database)->table($this->table); - } - /** * Prune all of the entries older than the given date. * @@ -137,8 +127,7 @@ protected function getTable() */ public function prune(DateTimeInterface $before) { - $query = $this->getTable() - ->where('failed_at', '<', $before); + $query = $this->getTable()->where('failed_at', '<', $before); $totalDeleted = 0; @@ -150,4 +139,14 @@ public function prune(DateTimeInterface $before) return $totalDeleted; } + + /** + * Get a new query builder instance for the table. + * + * @return \Illuminate\Database\Query\Builder + */ + protected function getTable() + { + return $this->resolver->connection($this->database)->table($this->table); + } }