From a777266e43a829435f383df2396f93e2b0fb8064 Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Tue, 1 Jul 2014 14:18:53 +1200 Subject: [PATCH] FIX ensure controller stack is updated when execution halted by an exception. See: https://github.com/silverstripe/silverstripe-framework/issues/2467 popCurrent would be incorrectly not pop a controller from the controller stack if an exception was throw from inside the handleRequest() method. This change captures the exception, ensures the controller is popped from the stack and passes the exception along. --- code/controllers/ContentController.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/code/controllers/ContentController.php b/code/controllers/ContentController.php index ce0bb148..0c7b4513 100644 --- a/code/controllers/ContentController.php +++ b/code/controllers/ContentController.php @@ -193,8 +193,18 @@ class ContentController extends Controller { } Director::set_current_page($this->data()); - $response = parent::handleRequest($request, $model); - Director::set_current_page(null); + + try { + $response = parent::handleRequest($request, $model); + + Director::set_current_page(null); + } catch(SS_HTTPResponse_Exception $e) { + $this->popCurrent(); + + Director::set_current_page(null); + + throw $e; + } } return $response;