Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.4] Revert queue prefix feature #18987

Merged
merged 1 commit into from
Apr 28, 2017
Merged
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
2 changes: 1 addition & 1 deletion src/Illuminate/Queue/BeanstalkdQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function deleteMessage($queue, $id)
*/
public function getQueue($queue)
{
return $this->getQueuePrefix().($queue ?: $this->default);
return $queue ?: $this->default;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Queue/DatabaseQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ protected function getNextAvailableJob($queue)
{
$job = $this->database->table($this->table)
->lockForUpdate()
->where('queue', $queue)
->where('queue', $this->getQueue($queue))
->where(function ($query) {
$this->isAvailable($query);
$this->isReservedButExpired($query);
Expand Down Expand Up @@ -308,7 +308,7 @@ public function deleteReserved($queue, $id)
*/
protected function getQueue($queue)
{
return $this->getQueuePrefix().($queue ?: $this->default);
return $queue ?: $this->default;
}

/**
Expand Down
30 changes: 0 additions & 30 deletions src/Illuminate/Queue/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ abstract class Queue
*/
protected $connectionName;

/**
* The queue prefix.
*
* @var string
*/
protected $queuePrefix;

/**
* Push a new job onto the queue.
*
Expand Down Expand Up @@ -185,29 +178,6 @@ public function setConnectionName($name)
return $this;
}

/**
* Set the queue name prefix.
*
* @param string $prefix
* @return $this
*/
public function setQueuePrefix($prefix = null)
{
$this->queuePrefix = $prefix;

return $this;
}

/**
* Get the queue name prefix.
*
* @return string
*/
public function getQueuePrefix()
{
return $this->queuePrefix;
}

/**
* Set the IoC container instance.
*
Expand Down
13 changes: 1 addition & 12 deletions src/Illuminate/Queue/QueueManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ protected function resolve($name)

return $this->getConnector($config['driver'])
->connect($config)
->setConnectionName($name)
->setQueuePrefix($this->getQueuePrefix());
->setConnectionName($name);
}

/**
Expand Down Expand Up @@ -244,16 +243,6 @@ public function getName($connection = null)
return $connection ?: $this->getDefaultDriver();
}

/**
* Get the queue name prefix.
*
* @return string
*/
public function getQueuePrefix()
{
return $this->app['config']->get('queue.prefix');
}

/**
* Determine if the application is in maintenance mode.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Queue/RedisQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ protected function getRandomId()
*/
protected function getQueue($queue)
{
return 'queues:'.$this->getQueuePrefix().($queue ?: $this->default);
return 'queues:'.($queue ?: $this->default);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Queue/SqsQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function pop($queue = null)
*/
public function getQueue($queue)
{
$queue = $this->getQueuePrefix().($queue ?: $this->default);
$queue = $queue ?: $this->default;

return filter_var($queue, FILTER_VALIDATE_URL) === false
? rtrim($this->prefix, '/').'/'.$queue : $queue;
Expand Down
33 changes: 12 additions & 21 deletions tests/Queue/QueueManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,41 @@ public function tearDown()

public function testDefaultConnectionCanBeResolved()
{
$config = new Repository([
'queue.default' => 'sync',
'queue.connections.sync' => ['driver' => 'sync'],
]);

$app = [
'config' => $config,
'config' => [
'queue.default' => 'sync',
'queue.connections.sync' => ['driver' => 'sync'],
],
'encrypter' => $encrypter = m::mock('Illuminate\Contracts\Encryption\Encrypter'),
];

$manager = new QueueManager($app);
$connector = m::mock('StdClass');
$queue = m::mock('StdClass');
$queue->shouldReceive('setConnectionName')->once()->with('sync')->andReturnSelf();
$queue->shouldReceive('setQueuePrefix')->once()->with('')->andReturnSelf();
$connector->shouldReceive('connect')->once()->with(['driver' => 'sync'])->andReturn($queue);
$manager->addConnector('sync', function () use ($connector) {
return $connector;
});
$queue->shouldReceive('setContainer')->once()->with($app);

$queue->shouldReceive('setContainer')->once()->with($app);
$this->assertSame($queue, $manager->connection('sync'));
}

public function testOtherConnectionCanBeResolved()
{
$config = new Repository([
'queue.default' => 'sync',
'queue.connections.foo' => ['driver' => 'bar'],
]);

$app = [
'config' => $config,
'config' => [
'queue.default' => 'sync',
'queue.connections.foo' => ['driver' => 'bar'],
],
'encrypter' => $encrypter = m::mock('Illuminate\Contracts\Encryption\Encrypter'),
];

$manager = new QueueManager($app);
$connector = m::mock('StdClass');
$queue = m::mock('StdClass');
$queue->shouldReceive('setConnectionName')->once()->with('foo')->andReturnSelf();
$queue->shouldReceive('setQueuePrefix')->once()->with('')->andReturnSelf();
$connector->shouldReceive('connect')->once()->with(['driver' => 'bar'])->andReturn($queue);
$manager->addConnector('bar', function () use ($connector) {
return $connector;
Expand All @@ -68,20 +62,17 @@ public function testOtherConnectionCanBeResolved()

public function testNullConnectionCanBeResolved()
{
$config = new Repository([
'queue.default' => 'null',
]);

$app = [
'config' => $config,
'config' => [
'queue.default' => 'null',
],
'encrypter' => $encrypter = m::mock('Illuminate\Contracts\Encryption\Encrypter'),
];

$manager = new QueueManager($app);
$connector = m::mock('StdClass');
$queue = m::mock('StdClass');
$queue->shouldReceive('setConnectionName')->once()->with('null')->andReturnSelf();
$queue->shouldReceive('setQueuePrefix')->once()->with('')->andReturnSelf();
$connector->shouldReceive('connect')->once()->with(['driver' => 'null'])->andReturn($queue);
$manager->addConnector('null', function () use ($connector) {
return $connector;
Expand Down