Skip to content

Commit 50a9491

Browse files
hansnntaylorotwell
andauthored
[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 <[email protected]>
1 parent 645f57a commit 50a9491

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Illuminate/Queue/Connectors/SyncConnector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ class SyncConnector implements ConnectorInterface
1414
*/
1515
public function connect(array $config)
1616
{
17-
return new SyncQueue;
17+
return new SyncQueue($config['after_commit'] ?? null);
1818
}
1919
}

src/Illuminate/Queue/SyncQueue.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@
1212

1313
class SyncQueue extends Queue implements QueueContract
1414
{
15+
/**
16+
* Create a new sync queue instance.
17+
*
18+
* @param bool $dispatchAfterCommit
19+
* @return void
20+
*/
21+
public function __construct($dispatchAfterCommit = false)
22+
{
23+
$this->dispatchAfterCommit = $dispatchAfterCommit;
24+
}
25+
1526
/**
1627
* Get the size of the queue.
1728
*

0 commit comments

Comments
 (0)