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

[8.x] Support job middleware on queued listeners #38128

Merged
merged 2 commits into from
Jul 26, 2021
Merged
Changes from 1 commit
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
Prev Previous commit
formatting
taylorotwell committed Jul 26, 2021
commit c01df37d75afc566ec550c27f59b49d0b8ba1b60
29 changes: 9 additions & 20 deletions src/Illuminate/Events/Dispatcher.php
Original file line number Diff line number Diff line change
@@ -557,13 +557,6 @@ protected function queueHandler($class, $method, $arguments)
? $listener->viaQueue()
: $listener->queue ?? null;

$job->through(
array_merge(
method_exists($listener, 'middleware') ? $listener->middleware() : [],
$listener->middleware ?? []
)
);

isset($listener->delay)
? $connection->laterOn($queue, $listener->delay, $job)
: $connection->pushOn($queue, $job);
@@ -596,22 +589,18 @@ protected function createListenerAndJob($class, $method, $arguments)
protected function propagateListenerOptions($listener, $job)
{
return tap($job, function ($job) use ($listener) {
$job->tries = $listener->tries ?? null;

$job->afterCommit = property_exists($listener, 'afterCommit') ? $listener->afterCommit : null;
$job->backoff = method_exists($listener, 'backoff') ? $listener->backoff() : ($listener->backoff ?? null);
$job->maxExceptions = $listener->maxExceptions ?? null;

$job->backoff = method_exists($listener, 'backoff')
? $listener->backoff() : ($listener->backoff ?? null);

$job->retryUntil = method_exists($listener, 'retryUntil') ? $listener->retryUntil() : null;
$job->shouldBeEncrypted = $listener instanceof ShouldBeEncrypted;
$job->timeout = $listener->timeout ?? null;
$job->tries = $listener->tries ?? null;

$job->afterCommit = property_exists($listener, 'afterCommit')
? $listener->afterCommit : null;

$job->retryUntil = method_exists($listener, 'retryUntil')
? $listener->retryUntil() : null;

$job->shouldBeEncrypted = $listener instanceof ShouldBeEncrypted;
$job->through(array_merge(
method_exists($listener, 'middleware') ? $listener->middleware() : [],
$listener->middleware ?? []
));
});
}