Skip to content
Browse files

fixed CErrorHandler discardOutput for php <5.3

only reset headers when there was an ob_gzhandler to avoid trouble with
apache mod_deflate
  • Loading branch information...
1 parent 85498dd commit d0bdf7be0c158ca09633cd892ce3569c4613fa1b @cebe cebe committed
Showing with 7 additions and 1 deletion.
  1. +7 −1 framework/base/CErrorHandler.php
View
8 framework/base/CErrorHandler.php
@@ -97,6 +97,12 @@ public function handle($event)
if($this->discardOutput)
{
+ $gzHandler=false;
+ foreach(ob_list_handlers() as $h)
+ {
+ if(strpos($h,'gzhandler')!==false)
+ $gzHandler=true;
+ }
// the following manual level counting is to deal with zlib.output_compression set to On
// for an output buffer created by zlib.output_compression set to On ob_end_clean will fail
for($level=ob_get_level();$level>0;--$level)
@@ -105,7 +111,7 @@ public function handle($event)
ob_clean();
}
// reset headers in case there was an ob_start("ob_gzhandler") before
- if(!headers_sent() && ob_list_handlers()===array())
+ if($gzHandler && !headers_sent() && ob_list_handlers()===array())
{
if(function_exists('header_remove')) // php >= 5.3
{

2 comments on commit d0bdf7b

@ieticaloocan

is it important to add those seven and delete the other 1??

@samdark
Yii Software LLC member

Yes, it is.

Please sign in to comment.
Something went wrong with that request. Please try again.