Magento 标头已发送
我对已经使用 Magento 发送的标头有这个问题。我收到此错误:
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
我看到了 这个 主题,但对我没有多大帮助。
我发现只有在通过管理面板导航并使用所见即所得编辑器编辑页面时才会收到此日志。当此类编辑的内容中有 .jpg 图像时,我会收到此标头已发送错误。
据我发现,它并不适用于所有图像,而是适用于其中一些图像。例如,当只有 1 个图像时,就不会出现错误。当有 3 个时,只有一个我会收到此错误。
我找不到任何空格或不需要的 echo
或 print
。我被这个问题困住了,我不知道要搜索什么。也许你可以给我一些建议?我知道这是无害的,但我们仍然不想在 system.log 中出现任何错误。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
返回控制器中的数据
有时我们会在 system.log 中看到“Headers Already Send...”...为了防止这种情况发生,我们应该使用这些方法之一干净地
:
$this->getResponse()->; setBody($response);
或肮脏的方式:
echo $response;
exit();
在某些情况下,“干净的方式”不起作用,所以我们必须使用“肮脏的方式”。
如果您通过 Ajax 获取内容,请使用此选项,就像在 CMS 中完成的那样;)
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 ;)
奇怪的是,我今天早上创建了这篇文章,因为我在调试 Magento 时遇到了一个非常相似的问题。
http://codemagento.com/2011/03/debugging-headers-已发送错误/
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/
或者,我们可以像 Magento 1.9.3 一样覆盖 \app\code\core\Mage\Adminhtml\controllers\Cms\WysiwygController.php 。在我们的例子中,这将函数directiveAction()的这一部分更改
为
更多信息(德语)右此处。使用 Magento CE 1.9.2.4 进行验证。
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()
to
Further information (in German) right here. Verified with Magento CE 1.9.2.4.