Reputation: 2550
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.
Upvotes: 4
Views: 5908
Reputation: 51
Alternatively we could overwrite \app\code\core\Mage\Adminhtml\controllers\Cms\WysiwygController.php in the same way Magento 1.9.3 does it. In our case this was changing this part of the function directiveAction()
try {
$image = Varien_Image_Adapter::factory('GD2');
$image->open($url);
$image->display();
} catch (Exception $e) {
$image = Varien_Image_Adapter::factory('GD2');
$image->open(Mage::getSingleton('cms/wysiwyg_config')->getSkinImagePlaceholderPath());
$image->display();
to
try {
$image = Varien_Image_Adapter::factory('GD2');
$image->open($url);
} catch (Exception $e) {
$image = Varien_Image_Adapter::factory('GD2');
$image->open(Mage::getSingleton('cms/wysiwyg_config')->getSkinImagePlaceholderPath());
}
ob_start();
$image->display();
$this->getResponse()->setBody(ob_get_contents());
ob_end_clean();
Further information (in German) right here. Verified with Magento CE 1.9.2.4.
Upvotes: 0
Reputation: 2282
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 ;)
Upvotes: 10
Reputation: 1
Oddly, I created this post just this morning since I ran into a very similar problem when debugging Magento.
http://codemagento.com/2011/03/debugging-headers-already-sent-error/
Upvotes: 0