Community Forums

Undefined variable and character display in Opera

Bug reports here

Undefined variable and character display in Opera

Postby fido-x » Fri Feb 06, 2009 2:11 am

I got the following error in Opera:--
Notice: Undefined variable: gzdata in system/library/response.php on line 50


The relevant line of code reads --
Code: Select all
$gzdata .= gzencode($data, (int)$level);


Changing this to --
Code: Select all
$gzdata = gzencode($data, (int)$level);

resolves this error.

However, the biggest issue is character display. See attached screenshot.
Attachments
opera.jpg
Last edited by fido-x on Fri Feb 06, 2009 2:13 am, edited 1 time in total.
Image
If you're not living on the edge ... you're taking up too much space!
Multi-Vendor Plugin for OpenCart 1.5.1.x
Have I helped you?
User avatar
fido-x
 
Posts: 1960
Joined: Fri Jun 27, 2008 5:09 pm
Location: Tasmania, Australia

Re: Undefined variable and character display in Opera

Postby bthirsk » Fri Feb 06, 2009 2:44 am

Fido
In \catalog\view\template\module/layout.tpl

swap line 1 with line 3
I think that will cure the rendering problem.
Brent
User avatar
bthirsk
 
Posts: 121
Joined: Wed Sep 03, 2008 3:33 am
Location: Canada

Re: Undefined variable and character display in Opera

Postby gaudi » Fri Feb 06, 2009 11:23 am

I encounter the same problem. I manage to resolve the $gzdata error using Fido instructions.

I also changed the layout.tpl template. The correct code I presumed should look like this:

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="<?php echo $direction; ?>" lang="<?php echo $language; ?>" xml:lang="<?php echo $language; ?>">
<?php echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; ?>
<head>


But the strange characters are still there.
gaudi
 
Posts: 8
Joined: Thu Feb 05, 2009 10:53 am

Re: Undefined variable and character display in Opera

Postby JNeuhoff » Fri Feb 06, 2009 1:21 pm

I can confirm this bug: I get the strange characters in Opera 9.63 and in Konqueror 4.1.3.

As a quick workaround, don't use the compression for the response output:

Code: Select all
   private function compress($data, $level = 4) {

//      if (strpos(@$_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
//         $encoding = 'gzip';
//      }

//      if (strpos(@$_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip')) {
//         $encoding = 'x-gzip';
//      }
      ......


This is not a complete solution, but at least it gets Opera and Konqueror going again.
J.Neuhoff - MHC Web Design

OpenCart Override Engine (Version 5.3)
allowing addons to override and modify core methods, language files and templates (see also FAQ)
User avatar
JNeuhoff
 
Posts: 2113
Joined: Tue Dec 04, 2007 7:38 pm

Re: Undefined variable and character display in Opera

Postby Daniel » Fri Feb 06, 2009 5:52 pm

i'm posting a fix for this in the next release. I think the strange charater problem issomthing to do with the database installer.
OpenCart®
Project Owner & Developer.
OpenCart commercial support now available!
User avatar
Daniel
Administrator
 
Posts: 5173
Joined: Fri Nov 03, 2006 10:57 am

Re: Undefined variable and character display in Opera

Postby Daniel » Fri Feb 06, 2009 6:03 pm

Copy and paste this into your response class:


Code: Select all
<?php
final class Response {
   private $headers = array();
   private $output;

   public function addHeader($key, $value) {
      $this->headers[$key] = $value;
   }

   public function removeHeader($key) {
      if (isset($this->headers[$key])) {
         unset($this->headers[$key]);
      }
   }

   public function redirect($url) {
      header('Location: ' . $url);
      exit;
   }

   public function setOutput($output) {
      $this->output = $output;
   }

   private function compress($data, $level = 4) {
      if (strpos(@$_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
         $encoding = 'gzip';
      }

      if (strpos(@$_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip')) {
         $encoding = 'x-gzip';
      }

      if (!isset($encoding)) {
         return $data;
      }

      if (!extension_loaded('zlib') || ini_get('zlib.output_compression')) {
         return $data;
      }

      if (headers_sent()) {
         return $data;
      }

      if (connection_status()) {
         return $data;
      }

      $gzdata = gzencode($data, (int)$level);

      $this->addHeader('Content-Encoding', $encoding);

      return $gzdata;
   }

   public function output($level = 4) {
      if ($level) {
         $ouput = $this->compress($this->output, $level);
      } else {
         $ouput = $this->output;
      }      
      
      foreach ($this->headers as $key => $value) {
         header($key. ': ' . $value);
      }
            
      echo $ouput;
   }
}
?>
OpenCart®
Project Owner & Developer.
OpenCart commercial support now available!
User avatar
Daniel
Administrator
 
Posts: 5173
Joined: Fri Nov 03, 2006 10:57 am

Re: Undefined variable and character display in Opera

Postby JNeuhoff » Fri Feb 06, 2009 7:00 pm

Thanks, that works. It looks like the HTTP-header 'Content-Encoding' needs to be placed before the other headers.
J.Neuhoff - MHC Web Design

OpenCart Override Engine (Version 5.3)
allowing addons to override and modify core methods, language files and templates (see also FAQ)
User avatar
JNeuhoff
 
Posts: 2113
Joined: Tue Dec 04, 2007 7:38 pm


Return to Bug Reports

Who is online

Users browsing this forum: Google Feedfetcher and 18 guests

Hosted by Arvixe Web Hosting