Skip to content

Commit

Permalink
[11.x] Consider after_commit config in SyncQueue (#51071)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
hansnn and taylorotwell authored Apr 15, 2024
1 parent 645f57a commit 50a9491
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Queue/Connectors/SyncConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ class SyncConnector implements ConnectorInterface
*/
public function connect(array $config)
{
return new SyncQueue;
return new SyncQueue($config['after_commit'] ?? null);
}
}
11 changes: 11 additions & 0 deletions src/Illuminate/Queue/SyncQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit 50a9491

Please sign in to comment.