We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

About Content Encoding Error

Development and Programming

biberltd's avatar
biberltd
54 posts
15 years ago
biberltd's avatar biberltd

I’ve been dealing with this error for few hours and finally figured out what was going on. I’m sharing it so that if you guys ever get into this same error you can have less pain.

To sum up I needed a custom fieldtype. I coded that then I went to templates, did whatever I needed to do. Then I typed in the url to check how the page looks. Everything was working when I was logged-out from EE 2.x. But I was getting Content Encoding Error when I was logged in.

the error code actually is this: ERR_CONTENT_DECODING_FAILED

I hit my head to walls couple times then I start putting “exit;” in variety places of my fieldtype. Then I noticed that there was a notice thrown due to non-existing array key.

Since debug information is not shown to visitors, the site was working for non-logged in people. On the other hand since there was a notice thrown to admins, I was getting the character encoding error message when I was logged-in.

Basically, since a lot of third party development is nicely abstracted in EE 2.x sometimes you get such weird errors before you see the actual errors. So it makes kinda hard to find what’s going on, if you are not experienced. The cause is simply that: your template outputs a header when called; and your abstracted add-on outputs an independent header when there is an error. Eventually, browser gets a little confused and it cannot show the page…

Just for your information.. 😊

Take Care

Can Berkol

       
Manuel Payano's avatar
Manuel Payano
144 posts
15 years ago
Manuel Payano's avatar Manuel Payano

Aha, i did notice such behaviors, but how do you prevent it?

       
Greg Aker's avatar
Greg Aker
6,022 posts
15 years ago
Greg Aker's avatar Greg Aker

are you having ExpressionEngine gzip output while developing?

       
biberltd's avatar
biberltd
54 posts
15 years ago
biberltd's avatar biberltd

@greg Yes we do use gzip.

@DevDemon

I can’t give you an exact recipe since this happens due to coding errors. If you are like me - a little lazy - unfortunately you need to stop making assumptions. Most of the time these notices occur due to simple assumptions.

For example, if you are coding a custom field type with a setting called “a_setting”.

Now i.e. if you want to make use of this setting in dipslay_field function, you directly use this:

$a_setting = $this->settings['a_setting'];

This is an assumption. You assume that the settings array has the key ‘a_setting’. If for some reason when saving the field a_setting is left blank, a_setting key will not be initialized in settings array.

Most (php) programmers, including me have the tendency to assume that a_setting will be automatically initialized when we call it since PHP gives us a little more freedom especially in assigning variables etc.

if you do simple checks however

$a_setting = '';
if(isset($this->settings['a_setting']{
   $a_setting = $this->settings['a_setting'];
}

you will be safe. Yes, you write more code, but your code will be more robust.

–

One other thing you can do is to turn off E_NOTICE output; but I do not reccomend that.

       
optima's avatar
optima
121 posts
15 years ago
optima's avatar optima

@DevDemon

We are experiencing this issue with your Channel Images addon in EE2. Are you aware of the issue and are there plans to resolve this issue?

Many thanks

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.