Skip to content

Commit

Permalink
BUGFIX Setting HTTP status in current controller for Debug::friendlyE…
Browse files Browse the repository at this point in the history
…rror() to avoid it being overwritten in HTTPResponse->output() later in the execution chain

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@92535 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information
chillu committed Nov 21, 2009
1 parent 204d4fb commit f3c0cbc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion dev/Debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,15 @@ static function friendlyError($statusCode = 500, $friendlyErrorMessage = null, $
if(!$friendlyErrorMessage) $friendlyErrorMessage = self::$friendly_error_header;
if(!$friendlyErrorDetail) $friendlyErrorDetail = self::$friendly_error_detail;

if(!headers_sent()) header($_SERVER['SERVER_PROTOCOL'] . " $statusCode $friendlyErrorMessage");
if(!headers_sent()) {
$currController = Controller::curr();
if($currController) {
$response = $currController->getResponse();
$response->setStatusCode($statusCode, $friendlyErrorMessage);
} else {
header($_SERVER['SERVER_PROTOCOL'] . " $statusCode $friendlyErrorMessage");
}
}

if(Director::is_ajax()) {
echo $friendlyErrorMessage;
Expand Down

0 comments on commit f3c0cbc

Please sign in to comment.