Ejemplo n.º 1
0
 /**
  * Fixes CGI only one Status header allowed bug
  *
  * @link  http://bugs.php.net/bug.php?id=36705
  *
  * @return Mage_Core_Controller_Response_Http
  */
 public function sendHeaders()
 {
     if (!$this->canSendHeaders()) {
         Mage::log('HEADERS ALREADY SENT: ' . mageDebugBacktrace(true, true, true));
         return $this;
     }
     if (substr(php_sapi_name(), 0, 3) == 'cgi') {
         $statusSent = false;
         foreach ($this->_headersRaw as $i => $header) {
             if (stripos($header, 'status:') === 0) {
                 if ($statusSent) {
                     unset($this->_headersRaw[$i]);
                 } else {
                     $statusSent = true;
                 }
             }
         }
         foreach ($this->_headers as $i => $header) {
             if (strcasecmp($header['name'], 'status') === 0) {
                 if ($statusSent) {
                     unset($this->_headers[$i]);
                 } else {
                     $statusSent = true;
                 }
             }
         }
     }
     return parent::sendHeaders();
 }
Ejemplo n.º 2
0
 protected function __getTrace($trace = null)
 {
     if (is_null($trace) && Mage::getStoreConfigFlag('carriers/udsplit/extco_check')) {
         $trace = mageDebugBacktrace(1, 0);
     }
     return $trace;
 }
Ejemplo n.º 3
0
 /**
  * handles the event application_clean_cache
  * @param Varien_Event $observer
  */
 public function applicationCleanCache($observer)
 {
     //$this->refreshCssOptimCache('application_clean_cache');
     $errorMessage = '$log[] = ' . var_export(array('$_SERVER' => $_SERVER), true) . ';' . PHP_EOL;
     ob_start();
     mageDebugBacktrace();
     $errorMessage .= ob_get_clean();
     file_put_contents(Mage::getBaseDir('var') . '/log/application_clean_cache.log', $errorMessage, FILE_APPEND);
 }
Ejemplo n.º 4
0
 /**
  * Fixes CGI only one Status header allowed bug
  *
  * @link  http://bugs.php.net/bug.php?id=36705
  *
  * @return Mage_Core_Controller_Response_Http
  */
 public function sendHeaders()
 {
     if (!$this->canSendHeaders()) {
         Mage::log('HEADERS ALREADY SENT: ' . mageDebugBacktrace(true, true, true));
         return $this;
     }
     if (substr(php_sapi_name(), 0, 3) == 'fpm') {
         $statusSent = FALSE;
         $contentSent = FALSE;
         foreach ($this->_headersRaw as $i => $header) {
             if (stripos($header, 'status:') === 0 || stripos($header, 'http/1.1') === 0) {
                 if ($statusSent) {
                     unset($this->_headersRaw[$i]);
                 } else {
                     $statusSent = true;
                 }
             }
             if (stripos($header, 'content-type') === 0) {
                 if ($contentSent) {
                     unset($this->_headersRaw[$i]);
                 } else {
                     $contentSent = true;
                 }
             }
         }
         foreach ($this->_headers as $i => $header) {
             if (strcasecmp($header['name'], 'status') === 0 || strcasecmp($header['name'], 'Http/1.1') === 0) {
                 if ($statusSent) {
                     unset($this->_headers[$i]);
                 } else {
                     $statusSent = true;
                 }
             }
             if (strcasecmp($header['name'], 'content-type') === 0) {
                 if ($contentSent || substr($header['value'], 0, 9) == 'text/html') {
                     unset($this->_headers[$i]);
                 } else {
                     $contentSent = true;
                 }
             }
         }
     }
     parent::sendHeaders();
 }
Ejemplo n.º 5
0
 /**
  * Fixes CGI only one Status header allowed bug
  * 17.10.2014 added Bugfix (2nd link)
  *
  * @link  http://bugs.php.net/bug.php?id=36705
  * @link  http://blog.swiftcore.com/2012/07/magento-duplicate-header-content-type-fastcgi-comm-with-server-xxxxxxx-aborted-error-parsing-headers.html
  *
  * @return Mage_Core_Controller_Response_Http
  */
 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
                 // FG Addition: Check if array key exists
                 if (array_key_exists($name, $sent) && $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
                 // FG Addition: Check if array key exists
                 if (array_key_exists($name, $sent) && $sent[$name]) {
                     unset($this->_headers[$i]);
                     continue;
                 }
                 // check header
                 // FG Addition: Check if array key exists
                 if (array_key_exists($name, $headers) && !is_null($existing = $headers[$name])) {
                     $this->_headers[$existing] = $header;
                     unset($this->_headers[$i]);
                 } else {
                     $headers[$name] = $i;
                 }
                 // check raw headers
                 // FG Addition: Check if array key exists
                 if (array_key_exists($name, $headersRaw) && !is_null($existing = $headersRaw[$name])) {
                     unset($this->_headersRaw[$existing]);
                 }
             }
         }
     }
     return parent::sendHeaders();
 }