-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] Emit PHP warning when Response::sendHeaders()
is called while output has already been sent
#60377
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
Conversation
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt calling error_log is fine: we should use the logger infrastructure instead.
But Response is not a service, it doesn't fit.
Then, I'm wondering which service could be responsible for doing this check and logging the issue.
Maybe ErrorListener since it already has a logger injected? Any other idea?
Response::sendHeaders()
I guess that's a possiblity that would work: @ivo95v up to update your PR? |
thank you @nicolas-grekas, sending header instead of error_log is a good idea. I just update the PR |
Response::sendHeaders()
Response::sendHeaders()
Response::sendHeaders()
Response::sendHeaders()
while output has already been sent
…output has already been sent
6359c43
to
a69cf15
Compare
Response::sendHeaders()
while output has already been sentResponse::sendHeaders()
is called while output has already been sent
Thank you @ivo95v. |
Description:
When Symfony attempts to send HTTP headers via the sendHeaders() method, it silently aborts if headers have already been sent (e.g., due to whitespace before the <?php tag). I spent an entire day debugging this issue and discovered that the problem was caused by an unintended whitespace before a PHP opening tag. To avoid this kind of silent failure and make future debugging easier, I decided to add an error log.