Magento 标头已发送

发布于 2024-10-20 19:17:44 字数 949 浏览 1 评论 0原文

我对已经使用 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 个时,只有一个我会收到此错误。

我找不到任何空格或不需要的 echoprint。我被这个问题困住了,我不知道要搜索什么。也许你可以给我一些建议?我知道这是无害的,但我们仍然不想在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

陪你搞怪i 2024-10-27 19:17:44

返回控制器中的数据

有时我们会在 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 ;)

酷到爆炸 2024-10-27 19:17:44

奇怪的是,我今天早上创建了这篇文章,因为我在调试 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/

蓝海 2024-10-27 19:17:44

或者,我们可以像 Magento 1.9.3 一样覆盖 \app\code\core\Mage\Adminhtml\controllers\Cms\WysiwygController.php 。在我们的例子中,这将函数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();

        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();

更多信息(德语)右此处。使用 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()

        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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文