Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fbd313e

Browse files
Merge pull request #131 from aaajeetee/master
Connection from task is not properly used when handling incoming task
2 parents 0589e26 + af443b8 commit fbd313e

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

‎src/TaskHandler.php‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Illuminate\Support\Str;
1414
use Illuminate\Validation\ValidationException;
1515
use Safe\Exceptions\JsonException;
16-
use stdClass;
1716
use UnexpectedValueException;
1817
use function Safe\json_decode;
1918

@@ -98,11 +97,8 @@ private function captureTask($task): array
9897

9998
private function loadQueueConnectionConfiguration(array $task): void
10099
{
101-
/**
102-
* @var stdClass $command
103-
*/
104100
$command = self::getCommandProperties($task['data']['command']);
105-
$connection = $command->connection ?? config('queue.default');
101+
$connection = $command['connection'] ?? config('queue.default');
106102
$baseConfig = config('queue.connections.' . $connection);
107103
$config = (new CloudTasksConnector())->connect($baseConfig)->config;
108104

‎tests/TaskHandlerTest.php‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,26 @@ public function it_can_run_a_task()
222222
Log::assertLogged('SimpleJob:success');
223223
}
224224

225+
/**
226+
* @test
227+
*/
228+
public function it_can_run_a_task_using_the_task_connection()
229+
{
230+
// Arrange
231+
OpenIdVerificator::fake();
232+
Log::swap(new LogFake());
233+
Event::fake([JobProcessing::class, JobProcessed::class]);
234+
$this->app['config']->set('queue.default', 'non-existing-connection');
235+
236+
// Act
237+
$job = new SimpleJob();
238+
$job->connection = 'my-cloudtasks-connection';
239+
$this->dispatch($job)->runWithoutExceptionHandler();
240+
241+
// Assert
242+
Log::assertLogged('SimpleJob:success');
243+
}
244+
225245
/**
226246
* @test
227247
*/

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /