-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
headers already sent by ... Response.php:1315 / SessionUtils.php:52 #59205
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
Comments
Same issue here. So it's relevant. |
Well, there's not much information to help you I am afraid. We will probably need a small example application that allows to debug. |
@THenkeDE Some questions we could minimze the scope of the problem?
|
Same issue here, it happens when streaming a PDF (using DOMPDF) to the browser Output started at : https://github.com/dompdf/dompdf/blob/master/src/Adapter/CPDF.php#L982 EDIT: I just changed to the Symfony way, ie: sending a binary response instead of using directly the "stream" method of the DOMPDF lib which is outputing content, causing the error with the kernel response AbstractSessionListener. |
We'd need a reproducer to understand the issue. |
PHP: 8.3, Symfony: 7.3.0 I have exceptions in my logs which look very similar:
The related code part is: // code part simplified to demonstrate the case
#[Route('/', name: 'home')]
public function handleRequest(): Response
{
$filepath = ROOT_PATH.'mbl-2025-7.pdf';
// load file and show in browser
header('Content-type:'. mime_content_type($filepath));
echo $this->filesystem->readFile($filepath); // <======== line 29, is mentioned in the error log
return new Response();
} Here is a reproducer based on the code of an proprietary app, so I hope it matches the case of the author and I extracted only the relevant code parts. https://github.com/k00ni/cannot-modify-header-reproducer I can provider further details if they are needed. The PDF file inside the repository is public domain by German law, in case that is relevant. Workaround?I solved it by replacing the mentioned code part with Symfony's // code part simplified to demonstrate the case
#[Route('/', name: 'home')]
public function handleRequest(): Response
{
$filepath = ROOT_PATH.'mbl-2025-7.pdf';
$response = new \Symfony\Component\HttpFoundation\BinaryFileResponse($filepath);
return $response;
} Symfony documentation provides further information about this class: https://symfony.com/doc/current/components/http_foundation.html#serving-files |
Symfony version(s) affected
6.4.*
Description
My prod.log is full with always the same Line:
php.WARNING: Warning: Cannot modify header information - headers already sent by (output started at localpath/vendor/symfony/http-foundation/Response.php:1315) {"exception":"[object] (ErrorException(code: 0): Warning: Cannot modify header information - headers already sent by (output started at localpath/vendor/symfony/http-foundation/Response.php:1315) at localpath/vendor/symfony/http-foundation/Session/SessionUtils.php:52)"} []
The causing Line (SessionUtils.php:52) removes the cookie Header
and the error is generated while flushing the output buffer
Is there anything i can do to fix this?
How to reproduce
sadly i have no Idea, it is just getted logged
Possible Solution
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: