Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
use Illuminate\Notifications\Console\NotificationTableCommand;
use Illuminate\Queue\Console\BatchesTableCommand;
use Illuminate\Queue\Console\ClearCommand as QueueClearCommand;
use Illuminate\Queue\Console\ContinueCommand as QueueContinueCommand;
use Illuminate\Queue\Console\FailedTableCommand;
use Illuminate\Queue\Console\FlushFailedCommand as FlushFailedQueueCommand;
use Illuminate\Queue\Console\ForgetFailedCommand as ForgetFailedQueueCommand;
Expand Down Expand Up @@ -148,7 +147,6 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid
'PackageDiscover' => PackageDiscoverCommand::class,
'PruneStaleTagsCommand' => PruneStaleTagsCommand::class,
'QueueClear' => QueueClearCommand::class,
'QueueContinue' => QueueContinueCommand::class,
'QueueFailed' => ListFailedQueueCommand::class,
'QueueFlush' => FlushFailedQueueCommand::class,
'QueueForget' => ForgetFailedQueueCommand::class,
Expand Down
21 changes: 21 additions & 0 deletions src/Illuminate/Queue/Console/Concerns/ParsesQueue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Illuminate\Queue\Console\Concerns;

trait ParsesQueue
{
/**
* Parse the queue argument into connection and queue name.
*
* @param string $queue
* @return array{string, string}
*/
protected function parseQueue($queue)
{
[$connection, $queue] = array_pad(explode(':', $queue, 2), 2, null);

return isset($queue)
? [$connection, $queue]
: [$this->laravel['config']['queue.default'], $connection];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the following?

return str_contains($queue, ':')
    ? explode(':', $queue, 2)
    : [$this->laravel['config']['queue.default'], $queue];

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong feeling about one being better than the other. I was just hoping to move this to a trait to avoid drift between the commands.

}
73 changes: 0 additions & 73 deletions src/Illuminate/Queue/Console/ContinueCommand.php

This file was deleted.

39 changes: 5 additions & 34 deletions src/Illuminate/Queue/Console/PauseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

use Illuminate\Console\Command;
use Illuminate\Contracts\Queue\Factory as QueueManager;
use Illuminate\Queue\Console\Concerns\ParsesQueue;
use Symfony\Component\Console\Attribute\AsCommand;

#[AsCommand(name: 'queue:pause')]
class PauseCommand extends Command
{
use ParsesQueue;

/**
* The console command name.
*
Expand All @@ -23,51 +26,19 @@ class PauseCommand extends Command
*/
protected $description = 'Pause job processing for a specific queue';

/**
* The queue manager instance.
*
* @var \Illuminate\Contracts\Queue\Factory
*/
protected $manager;

/**
* Create a new queue pause command.
*/
public function __construct(QueueManager $manager)
{
parent::__construct();

$this->manager = $manager;
}

/**
* Execute the console command.
*
* @return int
*/
public function handle()
public function handle(QueueManager $manager)
{
[$connection, $queue] = $this->parseQueue($this->argument('queue'));

$this->manager->pause($connection, $queue);
$manager->pause($connection, $queue);

$this->components->info("Job processing on queue [{$connection}:{$queue}] has been paused.");

return 0;
}

/**
* Parse the queue argument into the connection and queue name.
*
* @param string $queue
* @return array
*/
protected function parseQueue($queue)
{
[$connection, $queue] = array_pad(explode(':', $queue, 2), 2, null);

return isset($queue)
? [$connection, $queue]
: [$this->laravel['config']['queue.default'], $connection];
}
}
46 changes: 12 additions & 34 deletions src/Illuminate/Queue/Console/ResumeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

use Illuminate\Console\Command;
use Illuminate\Contracts\Queue\Factory as QueueManager;
use Illuminate\Queue\Console\Concerns\ParsesQueue;
use Symfony\Component\Console\Attribute\AsCommand;

#[AsCommand(name: 'queue:resume')]
#[AsCommand(name: 'queue:resume', aliases: ['queue:continue'])]
class ResumeCommand extends Command
{
use ParsesQueue;

/**
* The console command name.
*
Expand All @@ -17,57 +20,32 @@ class ResumeCommand extends Command
protected $signature = 'queue:resume {queue : The name of the queue that should resume processing}';

/**
* The console command description.
* The console command name aliases.
*
* @var string
* @var list<string>
*/
protected $description = 'Resume job processing for a paused queue';
protected $aliases = ['queue:continue'];
Copy link
Contributor

@vadimonus vadimonus Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is two command with same names realy needed?

here was just renaming one command to other. d8cbad4
maybe having two commands is some merging mistake?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good call, thanks for linking to the commit.

@taylorotwell let me know if you want me to keep ResumeCommand or ContinueCommand.


/**
* The queue manager instance.
* The console command description.
*
* @var \Illuminate\Contracts\Queue\Factory
*/
protected $manager;

/**
* Create a new queue resume command.
* @var string
*/
public function __construct(QueueManager $manager)
{
parent::__construct();

$this->manager = $manager;
}
protected $description = 'Resume job processing for a paused queue';

/**
* Execute the console command.
*
* @return int
*/
public function handle()
public function handle(QueueManager $manager)
{
[$connection, $queue] = $this->parseQueue($this->argument('queue'));

$this->manager->resume($connection, $queue);
$manager->resume($connection, $queue);

$this->components->info("Job processing on queue [{$connection}:{$queue}] has been resumed.");

return 0;
}

/**
* Parse the queue argument into connection and queue name.
*
* @param string $queue
* @return array
*/
protected function parseQueue($queue)
{
[$connection, $queue] = array_pad(explode(':', $queue, 2), 2, null);

return isset($queue)
? [$connection, $queue]
: [$this->laravel['config']['queue.default'], $connection];
}
}