2015-09-02 32 views
0

我添加了一個ajax添加到購物車的rwd主題,併爲每個http請求調用操作控制器兩次。歡迎任何解決問題或調試的幫助,我已經失去了2周的時間。這一切都適用於我們的開發環境,但在分期上表現奇怪。開發環境託管在本地MAMP上,分段託管在OVH共享託管上。Magento自定義控制器操作被調用兩次

EDIT2:去除不相關的信息

+0

給我你的網站地址 – SimBeez

回答

0

發現er​​ror.log中 的FastCGI此錯誤消息:與服務器通訊「/..../staging/index.php」流產:錯誤解析標題:重複的標題「的內容型」,引用者:http://staging.xxxx.be/product.html

還發現這裏的溶液:http://blog.imseo.it/2014/09/08/magento-fastcgi-error-parsing-headers-duplicate-header/

的解決方案是替代函數sendHeaders在 應用程序/代碼/核心/法師/核心/控制器/響應/ Http.php

public function sendHeaders() 
{ 
    if (!$this->canSendHeaders()) { 
     Mage::log('HEADERS ALREADY SENT: '.mageDebugBacktrace(true, true, true)); 
     return $this; 
    } 
    if (in_array(substr(php_sapi_name(), 0, 3), array('cgi', 'fpm'))) 
    { 
     // remove duplicate headers 
     $remove = array('status', 'content-type'); 

     // already sent headers 
     $sent = array(); 
     foreach (headers_list() as $header) 
     { 
      // parse name 
      if (!$pos = strpos($header, ':')) 
        continue; 
      $sent[strtolower(substr($header, 0, $pos))] = true; 
     } 

     // raw headers 
     $headersRaw = array(); 
     foreach ($this->_headersRaw as $i=>$header) 
     { 
      // parse name 
      if (!$pos = strpos($header, ':')) 
        continue; 
      $name = strtolower(substr($header, 0, $pos)); 

      if (in_array($name, $remove)) 
      { 
        // check sent headers 
        if ($sent[$name]) 
        { 
         unset($this->_headersRaw[$i]); 
         continue; 
        } 

        // check header 
        if (!is_null($existing = $headers[$name])) 
        { 
         $this->_headersRaw[$existing] = $header; 
         unset($this->_headersRaw[$i]); 
        } 
        else 
         $headersRaw[$name] = $i; 
      } 
     } 

     // object headers 
     $headers = array(); 
     foreach ($this->_headers as $i=>$header) 
     { 
      $name = strtolower($header['name']); 
      if (in_array($name, $remove)) 
      { 
        // check sent headers 
        if ($sent[$name]) 
        { 
         unset($this->_headers[$i]); 
         continue; 
        } 

        // check header 
        if (!is_null($existing = $headers[$name])) 
        { 
         $this->_headers[$existing] = $header; 
         unset($this->_headers[$i]); 
        } 
        else 
         $headers[$name] = $i; 

        // check raw headers 
        if (!is_null($existing = $headersRaw[$name])) 
         unset($this->_headersRaw[$existing]); 
      } 
     } 
    } 

    parent::sendHeaders(); 
}