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
@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.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.