Skip to content

[12.x] Pipeline::withinTransaction() accepts connection #56550

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

Merged
merged 5 commits into from
Aug 6, 2025
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
Next Next commit
pipeline transaction accepts connection
  • Loading branch information
cosmastech committed Aug 5, 2025
commit b3a568a6b978e715b40fa5635c5d56a11d1f20ee
11 changes: 6 additions & 5 deletions src/Illuminate/Pipeline/Pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Pipeline\Pipeline as PipelineContract;
use Illuminate\Support\Traits\Conditionable;
use UnitEnum;
use RuntimeException;
use Throwable;

Expand Down Expand Up @@ -51,7 +52,7 @@ class Pipeline implements PipelineContract
/**
* Indicates whether to wrap the pipeline in a database transaction.
*
* @var bool
* @var string|false|null|\UnitEnum
*/
protected $withinTransactions = false;

Expand Down Expand Up @@ -130,8 +131,8 @@ public function then(Closure $destination)
);

try {
return $this->withinTransactions
? $this->getContainer()->make('db')->transaction(fn () => $pipeline($this->passable))
return $this->withinTransactions !== false
? $this->getContainer()->make('db')->connection($this->withinTransactions)->transaction(fn () => $pipeline($this->passable))
: $pipeline($this->passable);
} finally {
if ($this->finally) {
Expand Down Expand Up @@ -257,10 +258,10 @@ protected function pipes()
/**
* Execute each pipeline step within a database transaction.
*
* @param bool $withinTransactions
* @param string|null|\UnitEnum|false $withinTransactions
* @return $this
*/
public function withinTransactions(bool $withinTransactions = true)
public function withinTransactions($withinTransactions = null)
{
$this->withinTransactions = $withinTransactions;

Expand Down
Loading