From d48ac40c632a83c9670905dc6541f1080d8cbdaa Mon Sep 17 00:00:00 2001 From: Mathieu De Zutter Date: Mon, 27 Aug 2018 18:29:39 +0200 Subject: [PATCH] Make sure sessions are cleaned after processing a request. PHP PM will catch any unexpected exception and kill the worker. --- Bridges/HttpKernel.php | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/Bridges/HttpKernel.php b/Bridges/HttpKernel.php index 07693f8..3308d67 100644 --- a/Bridges/HttpKernel.php +++ b/Bridges/HttpKernel.php @@ -81,22 +81,12 @@ public function handle(ServerRequestInterface $request) // headers_sent() returns true if any unbuffered output reaches cgi stdout. ob_start(); - try { - if ($this->bootstrap instanceof HooksInterface) { - $this->bootstrap->preHandle($this->application); - } - - $syResponse = $this->application->handle($syRequest); - } catch (\Exception $exception) { - // internal server error - error_log((string)$exception); - $response = new Psr7\Response(500, ['Content-type' => 'text/plain'], 'Unexpected error'); - - // end buffering if we need to throw - @ob_end_clean(); - return $response; + if ($this->bootstrap instanceof HooksInterface) { + $this->bootstrap->preHandle($this->application); } + $syResponse = $this->application->handle($syRequest); + $out = ob_get_clean(); $response = $this->mapResponse($syResponse, $out);