Magento Debug HEADERS ALREADY SENT error

前端 未结 11 582
盖世英雄少女心
盖世英雄少女心 2020-12-02 23:56

I am receiving the following error in my system.log file:

 2011-01-12T14:16:52+00:00 DEBUG (7): HEADERS ALREADY SENT: 
 [0] C:\\xampp\\htdocs\\www.mysite.com         


        
相关标签:
11条回答
  • 2020-12-03 00:53

    Here's the hard way.

    Find the location in the file that's doing the logging

    C:\xampp\htdocs\www.mysite.com\app\code\core\Mage\Core\Controller\Response\Http.php 
    Mage::log('HEADERS ALREADY SENT: '.mageDebugBacktrace(true, true, true));
    

    Add logging to get a copy of every file included/required so far

    Mage::log(print_r(get_included_files(),true));
    

    You can add this logging directly to the core file if you remember to restore the file to it's pre messed with condition, or you can add a temporary copy at

    app/code/local/Mage/Core/Controller/Response/Http.php
    

    as long as you remember to remove it when you're done (or just use git).

    Check this list of files for the usual white-space suspects, and then check them for any functions that might produce output (echo, print, readfile, there's probably more)

    0 讨论(0)
  • 2020-12-03 00:53

    In our case this was a bug in Magento CE 1.9.2.4, which was fixed in Magento CE 1.9.3, happened when using WYSIWYG with images. We just made a little extension which overwrites the function directiveAction() in \app\code\core\Mage\Adminhtml\controllers\Cms\WysiwygController.php. For more Details see (in German) here.

    0 讨论(0)
  • 2020-12-03 00:55

    I received this error when I built my Ajax request in a "hacky" way, echoing the contents directly instead of sending them out through the layout. Once I sent them out through the layout, the errors disappeared. See my own question here:

    Best way to output ajax data from a Magento Admin Extension

    props to @alan for his answer to my question.

    0 讨论(0)
  • 2020-12-03 00:55

    Same Issue while making Ajax Call

    I was getting the Log when i was making Ajax call and calling the template directly from controller.

    When i changed the code and created block in layout xml file. the log error got fixed.

    0 讨论(0)
  • 2020-12-03 00:58

    The most common place you run into this in Magento is when you output content directly from the controller.

    Instead of doing

    echo $string; 
    

    within a controller, do this:

    $this->getResponse()->setBody($string);
    
    0 讨论(0)
提交回复
热议问题