mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 00:48:25 +00:00
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:
parent
085c621c0e
commit
2bc58a5abd
1 changed files with 6 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue