diff --git a/lib/Cake/Error/ExceptionRenderer.php b/lib/Cake/Error/ExceptionRenderer.php index c855199f014..e991ac92410 100644 --- a/lib/Cake/Error/ExceptionRenderer.php +++ b/lib/Cake/Error/ExceptionRenderer.php @@ -263,6 +263,12 @@ protected function _outputMessage($template) { $this->controller->render($template); $this->controller->afterFilter(); $this->controller->response->send(); + } catch (MissingViewException $e) { + try { + $this->_outputMessage('error500'); + } catch (Exception $e) { + $this->_outputMessageSafe('error500'); + } } catch (Exception $e) { $this->_outputMessageSafe('error500'); } diff --git a/lib/Cake/Test/Case/Error/ExceptionRendererTest.php b/lib/Cake/Test/Case/Error/ExceptionRendererTest.php index 41c10113adc..e1fb8bd8bec 100644 --- a/lib/Cake/Test/Case/Error/ExceptionRendererTest.php +++ b/lib/Cake/Test/Case/Error/ExceptionRendererTest.php @@ -277,6 +277,49 @@ public function testErrorMethodCoercion() { $this->assertEquals($exception, $ExceptionRenderer->error); } +/** + * test that helpers in custom CakeErrorController are not lost + */ + public function testCakeErrorHelpersNotLost() { + $testApp = CAKE . 'Test' . DS . 'test_app' . DS; + App::build(array( + 'Controller' => array( + $testApp . 'Controller' . DS + ), + 'View/Helper' => array( + $testApp . 'View' . DS . 'Helper' . DS + ), + 'View/Layouts' => array( + $testApp . 'View' . DS . 'Layouts' . DS + ), + 'Error' => array( + $testApp . 'Error' . DS + ), + ), App::RESET); + Configure::write('Error', array( + 'handler' => 'TestAppsErrorHandler::handleError', + 'level' => E_ALL & ~E_DEPRECATED, + 'trace' => true + )); + + Configure::write('Exception', array( + 'handler' => 'TestAppsErrorHandler::handleException', + 'renderer' => 'TestAppsExceptionRenderer', + 'log' => true + )); + + App::uses('TestAppsErrorController', 'Controller'); + App::uses('TestAppsExceptionRenderer', 'Error'); + + $exception = new SocketException('socket exception'); + $renderer = new TestAppsExceptionRenderer($exception); + + ob_start(); + $renderer->render(); + $result = ob_get_clean(); + $this->assertContains('peeled', $result); + } + /** * test that unknown exception types with valid status codes are treated correctly. * diff --git a/lib/Cake/Test/test_app/Controller/TestAppsErrorController.php b/lib/Cake/Test/test_app/Controller/TestAppsErrorController.php new file mode 100644 index 00000000000..9ca1d7e3ba5 --- /dev/null +++ b/lib/Cake/Test/test_app/Controller/TestAppsErrorController.php @@ -0,0 +1,14 @@ + Configure::read('App.encoding'))); + try { + $controller = new TestAppsErrorController($request, $response); + $controller->layout = 'banana'; + } catch (Exception $e) { + $controller = new Controller($request, $response); + $controller->viewPath = 'Errors'; + } + return $controller; + } + +} diff --git a/lib/Cake/Test/test_app/View/Helper/BananaHelper.php b/lib/Cake/Test/test_app/View/Helper/BananaHelper.php index 1ceac01c97b..57759ac6a62 100644 --- a/lib/Cake/Test/test_app/View/Helper/BananaHelper.php +++ b/lib/Cake/Test/test_app/View/Helper/BananaHelper.php @@ -19,4 +19,9 @@ App::uses('Helper', 'View'); class BananaHelper extends Helper { + + public function peel() { + return 'peeled'; + } + } diff --git a/lib/Cake/Test/test_app/View/Layouts/banana.ctp b/lib/Cake/Test/test_app/View/Layouts/banana.ctp new file mode 100644 index 00000000000..b44e3aabb40 --- /dev/null +++ b/lib/Cake/Test/test_app/View/Layouts/banana.ctp @@ -0,0 +1,5 @@ + +Banana->peel(); +?> + \ No newline at end of file