我在 system.log 文件中收到以下错误:
2011-01-12T14:16:52+00:00 DEBUG (7): HEADERS ALREADY SENT:
[0] C:\xampp\htdocs\www.mysite.com\app\code\core\Mage\Core\Controller\Response\Http.php:44
[1] C:\xampp\htdocs\www.mysite.com\lib\Zend\Controller\Response\Abstract.php:727
[2] C:\xampp\htdocs\www.mysite.com\app\code\core\Mage\Core\Controller\Response\Http.php:75
[3] C:\xampp\htdocs\www.mysite.com\app\code\core\Mage\Core\Controller\Varien\Front.php:188
[4] C:\xampp\htdocs\www.mysite.com\app\code\core\Mage\Core\Model\App.php:304
[5] C:\xampp\htdocs\www.mysite.com\app\Mage.php:596
[6] C:\xampp\htdocs\www.mysite.com\index.php:81
我知道“已发送 header ”是什么意思,但我不知道是什么文件导致了这种情况,并且跟踪并没有真正给我任何信息。
有没有办法找出违规文件?
谢谢!
最佳答案
这是艰难的方式。
在进行日志记录的文件中找到位置
C:\xampp\htdocs\www.mysite.com\app\code\core\Mage\Core\Controller\Response\Http.php
Mage::log('HEADERS ALREADY SENT: '.mageDebugBacktrace(true, true, true));
添加日志记录以获取迄今为止包含/需要的每个文件的副本
Mage::log(print_r(get_included_files(),true));
如果您记得将文件恢复到预先弄乱的状态,则可以将此日志记录直接添加到核心文件中,或者您可以在以下位置添加临时副本
app/code/local/Mage/Core/Controller/Response/Http.php
只要您记得在完成后将其删除(或仅使用 git)。
检查此文件列表中是否存在常见的空白嫌疑人,然后检查它们是否有可能产生输出的任何函数(
echo
、 print
、 readfile
,可能还有更多)
关于debugging - Magento 调试头已发送错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4670031/