Skip to content

Commit

Permalink
Merge pull request #984 from cebe/error-handler-headers-sent
Browse files Browse the repository at this point in the history
improved CErrorHandler::discardOutput in case of gzipped output
  • Loading branch information
samdark committed Jul 16, 2012
2 parents 128f496 + d0bdf7b commit 98f636c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG
Expand Up @@ -32,7 +32,7 @@ Version 1.1.11 work in progress
- Bug #859: Fixed CSort::applyOrder() and CSort::getOrderBy() to use custom table aliases (troch, samdark)
- Bug #865: CLogRoute called processLogs() even if log array was empty and caused empty emails and log files (cebe)
- Bug #879: Fixed a possible PHP error caused by CWebUser::restoreFromCookie() in combination with CHttpRequest.enableCookieValidation (kidol)
- Bug #901: Fixed possible encoding problem on exception (mdomba, samdark)
- Bug #901: Fixed possible encoding problem on exception (mdomba, samdark, cebe)
- Bug #803: Arbitary non-sorting links in CDataColumn's header were not working proper way (resurtm)
- Bug: Fixed CMenu::isItemActive() to work properly when there is a hash in the item's url (SlKelevro)
- Bug: Added missing return statement to CAuthItem->revoke() (mdomba)
Expand Down
25 changes: 23 additions & 2 deletions framework/base/CErrorHandler.php
Expand Up @@ -97,12 +97,33 @@ 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)
{
@ob_end_clean();
if(!@ob_end_clean())
ob_clean();
}
// reset headers in case there was an ob_start("ob_gzhandler") before
if($gzHandler && !headers_sent() && ob_list_handlers()===array())
{
if(function_exists('header_remove')) // php >= 5.3
{
header_remove('Vary');
header_remove('Content-Encoding');
}
else
{
header('Vary:');
header('Content-Encoding:');
}
}
header("Content-Encoding: ", true);
}

if($event instanceof CExceptionEvent)
Expand Down

0 comments on commit 98f636c

Please sign in to comment.