Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento Headers already sent

Tags:

magento

I have this problem with Headers already sent with Magento. I get this error:

HEADERS ALREADY SENT: 
[0] /var/www/etam/trunk/src/app/code/core/Mage/Core/Controller/Response/Http.php:44
[1] /var/www/etam/trunk/src/lib/Zend/Controller/Response/Abstract.php:727
[2] /var/www/etam/trunk/src/app/code/core/Mage/Core/Controller/Response/Http.php:75
[3] /var/www/etam/trunk/src/app/code/core/Mage/Core/Controller/Varien/Front.php:188
[4] /var/www/etam/trunk/src/app/code/core/Mage/Core/Model/App.php:304
[5] /var/www/etam/trunk/src/app/Mage.php:596
[6] /var/www/etam/trunk/src/index.php:139

I saw this topic but didn't help me much.

I have found that this log I get only when navigating through Admin Panel and going to edit pages with WYSIWYG editor. When in the content of such edit there are .jpg images then I get this headers already sent error.

As far as I discovered it is not for all images but for some of them. For example when there is only 1 image no error then. When there are 3 of them, just for one I get this error.

I can't find any white spaces or unwanted echo nor print. I'm stuck with this and I'm out of ideas what to search for. Maybe you could give me some advices? I know it is harmless, still we don't want to have any errors in system.log.

like image 409
Ventus Avatar asked Dec 29 '22 00:12

Ventus


1 Answers

Sometimes we see "Headers Already Send..." in system.log... to prevent this we should return our data in controllers with one of those methods

clean way:

$this->getResponse()->setBody($response);

or dirty way:

echo $response;

exit();

There are some cases where "clean way" doesn't work, so we must use "dirty way".

Use this if You're getting content via Ajax, like it's done in CMS ;)

like image 68
xyz Avatar answered Jan 13 '23 19:01

xyz