Navigation Menu

Skip to content

Commit

Permalink
Added check if Router::getRequest(false) is returning a CakeRequest o…
Browse files Browse the repository at this point in the history
…r null in ExceptionRenderer::_getController(). Fixes 'call to undefined method here()' when having Exceptions raised without valid request set to the Router in testsuite (i.e. undefined database config 'test'). Fixes #1678 .

Conflicts:

	lib/Cake/Error/ExceptionRenderer.php
  • Loading branch information
markstory committed May 17, 2011
1 parent 085c621 commit 2bc58a5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/Cake/Error/ExceptionRenderer.php
Expand Up @@ -141,13 +141,17 @@ function __construct(Exception $exception) {
*
* @param Exception $exception The exception to get a controller for.
* @return Controller
* @access protected
*/
protected function _getController($exception) {
App::uses('CakeErrorController', 'Controller');
if (!$request = Router::getRequest(false)) {
$request = new CakeRequest();
}
try {
$controller = new CakeErrorController(Router::getRequest(false));
$controller = new CakeErrorController($request);
} catch (Exception $e) {
$controller = new Controller(Router::getRequest(false));
$controller = new Controller($request);
$controller->viewPath = 'Errors';
}
return $controller;
Expand Down

0 comments on commit 2bc58a5

Please sign in to comment.