From 095d9221e837e7a7d8bd00d14184e619b962173a Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 9 Dec 2020 09:33:12 -0600 Subject: [PATCH] formatting --- src/Illuminate/Bus/Queueable.php | 6 ++-- src/Illuminate/Events/Dispatcher.php | 4 +++ .../Foundation/Bus/PendingDispatch.php | 4 +-- src/Illuminate/Queue/Queue.php | 35 ++++++------------- 4 files changed, 20 insertions(+), 29 deletions(-) diff --git a/src/Illuminate/Bus/Queueable.php b/src/Illuminate/Bus/Queueable.php index 5cf4777620b5..b371e3bb21cc 100644 --- a/src/Illuminate/Bus/Queueable.php +++ b/src/Illuminate/Bus/Queueable.php @@ -53,7 +53,7 @@ trait Queueable public $delay; /** - * Indicate the job should be dispatched after database transactions. + * Indicates whether the job should be dispatched after all database transactions have committed. * * @var bool|null */ @@ -141,7 +141,7 @@ public function delay($delay) } /** - * Indicate that the job should be dispatched after database transactions. + * Indicate that the job should be dispatched after all database transactions have committed. * * @return $this */ @@ -153,7 +153,7 @@ public function afterCommit() } /** - * Indicate that the job should be dispatched before database transactions. + * Indicate that the job should not wait until database transactions have been committed before dispatching. * * @return $this */ diff --git a/src/Illuminate/Events/Dispatcher.php b/src/Illuminate/Events/Dispatcher.php index 9116c2f0c3f5..58f65a4bdbd2 100755 --- a/src/Illuminate/Events/Dispatcher.php +++ b/src/Illuminate/Events/Dispatcher.php @@ -554,11 +554,15 @@ protected function propagateListenerOptions($listener, $job) { return tap($job, function ($job) use ($listener) { $job->tries = $listener->tries ?? null; + $job->backoff = method_exists($listener, 'backoff') ? $listener->backoff() : ($listener->backoff ?? null); + $job->timeout = $listener->timeout ?? null; + $job->dispatchAfterCommit = property_exists($listener, 'dispatchAfterCommit') ? $listener->dispatchAfterCommit : null; + $job->retryUntil = method_exists($listener, 'retryUntil') ? $listener->retryUntil() : null; }); diff --git a/src/Illuminate/Foundation/Bus/PendingDispatch.php b/src/Illuminate/Foundation/Bus/PendingDispatch.php index 1d54b9534bd2..8ac4432319a9 100644 --- a/src/Illuminate/Foundation/Bus/PendingDispatch.php +++ b/src/Illuminate/Foundation/Bus/PendingDispatch.php @@ -100,7 +100,7 @@ public function delay($delay) } /** - * Indicate that the job should be dispatched after database transactions. + * Indicate that the job should be dispatched after all database transactions have committed. * * @return $this */ @@ -112,7 +112,7 @@ public function afterCommit() } /** - * Indicate that the job should be dispatched before database transactions. + * Indicate that the job should not wait until database transactions have been committed before dispatching. * * @return $this */ diff --git a/src/Illuminate/Queue/Queue.php b/src/Illuminate/Queue/Queue.php index b8f525918098..5cb73576604e 100755 --- a/src/Illuminate/Queue/Queue.php +++ b/src/Illuminate/Queue/Queue.php @@ -5,6 +5,7 @@ use Closure; use DateTimeInterface; use Illuminate\Container\Container; +use Illuminate\Database\DatabaseTransactionManager; use Illuminate\Support\Arr; use Illuminate\Support\InteractsWithTime; use Illuminate\Support\Str; @@ -28,18 +29,18 @@ abstract class Queue protected $connectionName; /** - * The create payload callbacks. + * Indicates that jobs should be dispatched after all database transactions have committed. * - * @var callable[] + * @return $this */ - protected static $createPayloadCallbacks = []; + protected $dispatchAfterCommit; /** - * Indicate the job should be dispatched after database transactions. + * The create payload callbacks. * - * @var bool|null + * @var callable[] */ - protected $dispatchAfterCommit; + protected static $createPayloadCallbacks = []; /** * Push a new job onto the queue. @@ -278,7 +279,9 @@ protected function enqueueUsing($job, $payload, $queue, $delay, $callback) if ($this->shouldDispatchAfterCommit($job) && $this->container->bound('db.transactions')) { return $this->container->make('db.transactions')->addCallback( - $this->afterCommitCallback($payload, $queue, $delay, $callback) + function () use ($payload, $queue, $delay, $callback) { + return $callback($payload, $queue, $delay); + } ); } @@ -286,7 +289,7 @@ protected function enqueueUsing($job, $payload, $queue, $delay, $callback) } /** - * Determine if the job should be dispatched after database transactions. + * Determine if the job should be dispatched after all database transactions have committed. * * @param \Closure|string|object $job * @return bool @@ -304,22 +307,6 @@ protected function shouldDispatchAfterCommit($job) return false; } - /** - * Create the after commit callback. - * - * @param string $payload - * @param string $queue - * @param \DateTimeInterface|\DateInterval|int|null $delay - * @param callable $callback - * @return callable - */ - protected function afterCommitCallback($payload, $queue, $delay, $callback) - { - return function () use ($delay, $queue, $payload, $callback) { - return $callback($payload, $queue, $delay); - }; - } - /** * Get the connection name for the queue. *