Skip to content

Commit

Permalink
Fix exceptions being thrown in beforeFilter breaking error pages.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
markstory committed Nov 24, 2012
1 parent e04e0a0 commit 3083b01
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 0 additions & 2 deletions lib/Cake/Controller/CakeErrorController.php
Expand Up @@ -66,8 +66,6 @@ public function __construct($request = null, $response = null) {
if ($this->Components->enabled('Security')) {
$this->Components->disable('Security');
}
$this->startupProcess();

$this->_set(array('cacheAction' => false, 'viewPath' => 'Errors'));
}

Expand Down
4 changes: 4 additions & 0 deletions lib/Cake/Error/ExceptionRenderer.php
Expand Up @@ -150,7 +150,11 @@ protected function _getController($exception) {
$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);
Expand Down

0 comments on commit 3083b01

Please sign in to comment.