diff --git a/admin/code/LeftAndMain.php b/admin/code/LeftAndMain.php index 0e488c48f21..16914770e7e 100644 --- a/admin/code/LeftAndMain.php +++ b/admin/code/LeftAndMain.php @@ -358,6 +358,17 @@ function redirect($url, $code=302) { if($this->request->getHeader('X-Pjax') && !$this->response->getHeader('X-Pjax')) { $this->response->addHeader('X-Pjax', $this->request->getHeader('X-Pjax')); } + $oldResponse = $this->response; + $newResponse = new LeftAndMain_HTTPResponse( + $oldResponse->getBody(), + $oldResponse->getStatusCode(), + $oldResponse->getStatusDescription() + ); + foreach($oldResponse->getHeaders() as $k => $v) { + $newResponse->addHeader($k, $v); + } + $newResponse->setIsFinished(true); + $this->response = $newResponse; return ''; // Actual response will be re-requested by client } else { parent::redirect($url, $code); @@ -1471,3 +1482,19 @@ function mark($node) { } } +/** + * Allow overriding finished state for faux redirects. + */ +class LeftAndMain_HTTPResponse extends SS_HTTPResponse { + + protected $isFinished = false; + + function isFinished() { + return (parent::isFinished() || $this->isFinished); + } + + function setIsFinished($bool) { + $this->isFinished = $bool; + } + +} \ No newline at end of file