【问题标题】:Cannot sent headers error after SUPEE 6788 patch MagentoSUPEE 6788 补丁 Magento 后无法发送标头错误
【发布时间】:2016-04-26 13:32:34
【问题描述】:

我在我的 Magento 1.9.1.0 上使用模板,在使用 SUPEE 6788 进行修补后,我的 system.log 中出现以下错误:

2016-04-26T00:50:23+00:00 DEBUG (7): Cannot send headers; headers already sent in /usr/share/nginx/html/app/code/community/Ves/Tabs/controllers/IndexController.php, line 140
2016-04-26T00:50:23+00:00 DEBUG (7): HEADERS ALREADY SENT: <pre>[0] /usr/share/nginx/html/app/code/core/Mage/Core/Controller/Response/Http.php:52
[1] /usr/share/nginx/html/lib/Zend/Controller/Response/Abstract.php:771
[2] /usr/share/nginx/html/app/code/core/Mage/Core/Controller/Response/Http.php:84
[3] /usr/share/nginx/html/app/code/core/Mage/Core/Controller/Varien/Front.php:184
[4] /usr/share/nginx/html/app/code/core/Mage/Core/Model/App.php:354
[5] /usr/share/nginx/html/app/Mage.php:684
[6] /usr/share/nginx/html/index.php:87

在第 140 行的 IndexController.php 中,我有以下代码:

echo Mage::helper('core')->jsonEncode( $json );

我认为调用 json 的方式会导致此错误。我该如何解决这个问题?

提前致谢。

【问题讨论】:

  • 您是否在某些文件的结束 php 标记之后或开始标记之前检查了空格?也看看这个..stackoverflow.com/questions/4670031/…
  • @severinolorillajr 我验证了每个文件都没有成功。
  • @Hallan 请注意,由于您使用的是社区模块,因此您可能应该首先向 Ves 支持团队寻求帮助
  • 你想用上面的代码实现什么。您是否需要发送编码数据以响应某处?你能跟我说清楚吗
  • @severinolorillajr 我按照您过去链接中的说明操作,并在本页末尾提供 sagar umaretiya 答案。非常感谢。

标签: php json magento


【解决方案1】:

我从上述问题中了解到,您希望对数据进行编码并在程序中的某处使用它。

如果上述情况属实,那么您可以尝试以下解决方案。

$this->getResponse()->clearHeaders()->setHeader('content-type', 'application/json', true);
$this->getResponse()->setBody(json_encode($json));

谢谢

【讨论】:

  • 谢谢萨加尔!我尝试了第二行。我替换了“echo”行,这解决了我的问题。
  • 嘿哈伦。我很高兴听到这个。加油!
猜你喜欢
  • 2016-02-19
  • 1970-01-01
  • 1970-01-01
  • 2016-02-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多