From 50a9491fc46bcb929f2b976daa349a123cf7b45c Mon Sep 17 00:00:00 2001 From: Martin Hansen Date: Mon, 15 Apr 2024 20:33:24 +0200 Subject: [PATCH] [11.x] Consider after_commit config in SyncQueue (#51071) * Consider after_commit config in SyncQueue AfterCommit support was added to the SyncQueue in #48860. However, it only works if the job in question implements the ShouldQueueAfterCommit interface or sets the afterCommit property - it does not work if after_commit is set to true in the sync driver's configuration. This makes the behavior inconsistent, which is what this commit solves by also considering the after_commit config. * Update SyncQueue.php * Update SyncQueue.php --------- Co-authored-by: Taylor Otwell --- src/Illuminate/Queue/Connectors/SyncConnector.php | 2 +- src/Illuminate/Queue/SyncQueue.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Queue/Connectors/SyncConnector.php b/src/Illuminate/Queue/Connectors/SyncConnector.php index 4269b803927f..5427d3afae5d 100755 --- a/src/Illuminate/Queue/Connectors/SyncConnector.php +++ b/src/Illuminate/Queue/Connectors/SyncConnector.php @@ -14,6 +14,6 @@ class SyncConnector implements ConnectorInterface */ public function connect(array $config) { - return new SyncQueue; + return new SyncQueue($config['after_commit'] ?? null); } } diff --git a/src/Illuminate/Queue/SyncQueue.php b/src/Illuminate/Queue/SyncQueue.php index c687635ee3ea..57974960d4bb 100755 --- a/src/Illuminate/Queue/SyncQueue.php +++ b/src/Illuminate/Queue/SyncQueue.php @@ -12,6 +12,17 @@ class SyncQueue extends Queue implements QueueContract { + /** + * Create a new sync queue instance. + * + * @param bool $dispatchAfterCommit + * @return void + */ + public function __construct($dispatchAfterCommit = false) + { + $this->dispatchAfterCommit = $dispatchAfterCommit; + } + /** * Get the size of the queue. *