Browse Source

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
mark_story 15 years ago
parent
commit
2bc58a5abd
1 changed files with 6 additions and 2 deletions
  1. 6 2
      lib/Cake/Error/ExceptionRenderer.php

+ 6 - 2
lib/Cake/Error/ExceptionRenderer.php

@@ -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;