0

At this moment I have a problem with a Magento installation. This turns out hard to find for me.

The problem:

the system.log file has lots of headers already sent entries.

2016-06-08T10:01:35+00:00 DEBUG (7): File: /data/web/public/lib/Zend/Controller/Response/Abstract.php
2016-06-08T10:01:35+00:00 DEBUG (7): Line: 595
2016-06-08T10:01:35+00:00 DEBUG (7): HEADERS ALREADY SENT: <pre>[0] /data/web/public/app/code/core/Mage/Core/Controller/Response/Http.php:52
[1] /data/web/public/lib/Zend/Controller/Response/Abstract.php:775
[2] /data/web/public/app/code/core/Mage/Core/Controller/Response/Http.php:89
[3] /data/web/public/app/code/core/Mage/Core/Controller/Varien/Front.php:184
[4] /data/web/public/app/code/core/Mage/Core/Model/App.php:354
[5] /data/web/public/app/Mage.php:684
[6] /data/web/public/index.php:96
</pre>

I modified the /lib/Zend/Controller/Response/Abstract.php file to see what file and line is causing the problem and this is where i get stuck. Line 595 is the echo of the function

public function outputBody()
{
    $body = implode('', $this->_body);
    echo $body;
}

I also modifed a script to output all included files and tested those for blanklines and php closing tags. no succes there either. (I assume a php closing in phtml is not an problem?)

Who can help me with this issue?

thanks.

  • 1
    Possible duplicate of [How to fix "Headers already sent" error in PHP](http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php) – Chetan Ameta Jun 08 '16 at 10:14
  • I think you are looking at false position. before this echo, your script is executing some other echo, then on this position your are getting this error. – user3733648 Jun 08 '16 at 10:25
  • Yes, you are correct, a php closing in phtml is not an problem. Try to log the request URI, controller, action, to check if the error raised for all actions either for a particular action. Usually such notice is logged in controller actions which send some file as an attachment, i.e. files downloading actions. Such actions should not send default Magento response and I suggest to exit() right in your controller. – Neklo.com Jun 08 '16 at 10:34
  • Do you have any cron job running ? any scripts or code which is like "$this -> getResponse() -> setHeader('Content-Type', 'application/json') -> setHeader('Session-Id', $session_id) -> appendBody(json_encode($result));" – Anurag Prashant Jun 09 '16 at 06:19
  • I have extended the logging with request URI and SERVER_NAME. Errors are comming from browsing categories and viewing products. This does not yet make any sence to me. The File: and Line: values for log entry are variables set from canSendHeaders $ok = headers_sent($file, $line); – Peter Voskuilen Jun 09 '16 at 12:05
  • I was also led to `public function outputBody()`: how did you solve it? and find the underlying culprit? – snh_nl Jan 23 '17 at 14:00

0 Answers0