From c58e7da6676e190cc19aa0ddd1f673eaee94e86e Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 13 Dec 2014 15:04:11 -0500 Subject: [PATCH 1/3] Handle exception when RequestHandler::startup() fails. In the case that there is a request data type parser raises an exception, or startup() otherwise fails the error page should be created correctly. While I'm not able to write a test case for this, manual testing confirmed the fix. Refs #5311 --- lib/Cake/Error/ExceptionRenderer.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Error/ExceptionRenderer.php b/lib/Cake/Error/ExceptionRenderer.php index 3da88679e..0a8490208 100644 --- a/lib/Cake/Error/ExceptionRenderer.php +++ b/lib/Cake/Error/ExceptionRenderer.php @@ -153,9 +153,14 @@ class ExceptionRenderer { try { $controller = new CakeErrorController($request, $response); $controller->startupProcess(); + $startup = true; } catch (Exception $e) { - if (!empty($controller) && $controller->Components->enabled('RequestHandler')) { + $startup = false; + } + if ($startup === false && !empty($controller) && $controller->Components->enabled('RequestHandler')) { + try { $controller->RequestHandler->startup($controller); + } catch (Exception $e) { } } } From f19916bccf627535e77e496c95fd4e0e20e8ea46 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 13 Dec 2014 22:25:52 -0500 Subject: [PATCH 2/3] Add comments for possibly confusing code. --- lib/Cake/Error/ExceptionRenderer.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Error/ExceptionRenderer.php b/lib/Cake/Error/ExceptionRenderer.php index 0a8490208..ad36fea3e 100644 --- a/lib/Cake/Error/ExceptionRenderer.php +++ b/lib/Cake/Error/ExceptionRenderer.php @@ -157,7 +157,13 @@ class ExceptionRenderer { } catch (Exception $e) { $startup = false; } - if ($startup === false && !empty($controller) && $controller->Components->enabled('RequestHandler')) { + // Retry RequestHandler, as another aspect of startupProcess() + // could have failed. Ignore any exceptions out of startup, as + // there could be userland input data parsers. + if ($startup === false && + !empty($controller) && + $controller->Components->enabled('RequestHandler') + ) { try { $controller->RequestHandler->startup($controller); } catch (Exception $e) { From ae8a540101976d38d9114d2e62bd424dc34513b1 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 14 Dec 2014 18:05:20 -0500 Subject: [PATCH 3/3] Remove trailing whitespace. --- lib/Cake/Error/ExceptionRenderer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Error/ExceptionRenderer.php b/lib/Cake/Error/ExceptionRenderer.php index ad36fea3e..04190eba5 100644 --- a/lib/Cake/Error/ExceptionRenderer.php +++ b/lib/Cake/Error/ExceptionRenderer.php @@ -158,7 +158,7 @@ class ExceptionRenderer { $startup = false; } // Retry RequestHandler, as another aspect of startupProcess() - // could have failed. Ignore any exceptions out of startup, as + // could have failed. Ignore any exceptions out of startup, as // there could be userland input data parsers. if ($startup === false && !empty($controller) &&