Skip to content

[12.x] Use getContainer() to avoid fatal error in Pipeline with transactions #56447

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 2 commits into from
Jul 27, 2025

Conversation

xurshudyan
Copy link
Contributor

Currently, the Pipeline class directly accesses $this->container when running the pipeline within a database transaction:

$this->container->make('db')->transaction(fn () => $pipeline($this->passable));

If the container is not set, this causes a fatal error:

Call to a member function make() on null

This error is unhelpful and makes debugging difficult.

This PR improves the robustness of the Pipeline by replacing the direct container access with the existing getContainer() method, which throws a clear and descriptive RuntimeException if the container is missing:

$this->getContainer()->make('db')->transaction(fn () => $pipeline($this->passable));

This ensures that users get a meaningful error message:

A container instance has not been passed to the Pipeline.

Additionally, a test was added to verify this behavior when transactions are enabled but no container is set.

@taylorotwell taylorotwell merged commit a182063 into laravel:12.x Jul 27, 2025
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants