Added check if Router::getRequest(false) is returning a CakeRequest or 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
This commit is contained in:
mark_story 2011-05-16 21:11:33 -04:00
parent 085c621c0e
commit 2bc58a5abd

View file

@ -141,13 +141,17 @@ class ExceptionRenderer {
*
* @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;