From 3083b01f7d6a756416d493a8fc8c23819e33c20b Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 24 Nov 2012 15:38:42 -0500 Subject: [PATCH] Fix exceptions being thrown in beforeFilter breaking error pages. If an exception was raised in the AppController::beforeFilter(), requests for content-type responses would render as HTML. Extracting the startupProcess() allows us to keep a reference to the error controller, which can be used to force startup RequestHandlerComponent if its enabled. Fixes #3389 --- lib/Cake/Controller/CakeErrorController.php | 2 -- lib/Cake/Error/ExceptionRenderer.php | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Controller/CakeErrorController.php b/lib/Cake/Controller/CakeErrorController.php index c1835fd6e..53f500217 100644 --- a/lib/Cake/Controller/CakeErrorController.php +++ b/lib/Cake/Controller/CakeErrorController.php @@ -66,8 +66,6 @@ class CakeErrorController extends AppController { if ($this->Components->enabled('Security')) { $this->Components->disable('Security'); } - $this->startupProcess(); - $this->_set(array('cacheAction' => false, 'viewPath' => 'Errors')); } diff --git a/lib/Cake/Error/ExceptionRenderer.php b/lib/Cake/Error/ExceptionRenderer.php index 3be08d26c..b315a36cd 100644 --- a/lib/Cake/Error/ExceptionRenderer.php +++ b/lib/Cake/Error/ExceptionRenderer.php @@ -150,7 +150,11 @@ class ExceptionRenderer { $response = new CakeResponse(array('charset' => Configure::read('App.encoding'))); try { $controller = new CakeErrorController($request, $response); + $controller->startupProcess(); } catch (Exception $e) { + if (!empty($controller) && $controller->Components->enabled('RequestHandler')) { + $controller->RequestHandler->startup($controller); + } } if (empty($controller)) { $controller = new Controller($request, $response);