Skip to content
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

call end() when redirecting #15014

Merged
merged 3 commits into from
May 17, 2024
Merged

Conversation

timkelty
Copy link
Contributor

Description

Without this, redirects can cause Response::send() to be called multiple times, causing HeadersAlreadySentException to be thrown.

Example:

  • A controller calls $this->response->sendFile()
  • A listener on \yii\web\Response::EVENT_AFTER_PREPARE calls Response::redirect()
  • That triggers another Response::send(), which sends headers
  • The remaining calls to Response::send() (from $app->run) attempt to send headers, throwing HeadersAlreadySentException.

@timkelty timkelty requested a review from brandonkelly May 16, 2024 20:27
@brandonkelly brandonkelly merged commit df84dc4 into 4.x May 17, 2024
@brandonkelly brandonkelly deleted the bugfix/prevent-redirect-recursion branch May 17, 2024 19:54
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