From 79c82c90cc776986d4c623c7fb567e705c2550a7 Mon Sep 17 00:00:00 2001 From: Simon Sessingo Date: Tue, 27 Feb 2018 08:20:25 +0100 Subject: [PATCH] Fixed issue with PDO exception not returning correct type for error-code. --- src/Pecee/Http/Security/CookieTokenProvider.php | 2 +- src/Pecee/SimpleRouter/Router.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Pecee/Http/Security/CookieTokenProvider.php b/src/Pecee/Http/Security/CookieTokenProvider.php index 5df9509..209067f 100644 --- a/src/Pecee/Http/Security/CookieTokenProvider.php +++ b/src/Pecee/Http/Security/CookieTokenProvider.php @@ -36,7 +36,7 @@ class CookieTokenProvider implements ITokenProvider try { return bin2hex(random_bytes(32)); } catch(\Exception $e) { - throw new SecurityException($e->getMessage(), $e->getCode(), $e->getPrevious()); + throw new SecurityException($e->getMessage(), (int)$e->getCode(), $e->getPrevious()); } } diff --git a/src/Pecee/SimpleRouter/Router.php b/src/Pecee/SimpleRouter/Router.php index af457d6..905bfb4 100644 --- a/src/Pecee/SimpleRouter/Router.php +++ b/src/Pecee/SimpleRouter/Router.php @@ -124,6 +124,11 @@ class Router $exceptionHandlers = []; + // Stop processing routes if no valid route is found. + if($this->request->getRewriteRoute() === null && $this->request->getUrl() === null) { + return; + } + $url = ($this->request->getRewriteUrl() !== null) ? $this->request->getRewriteUrl() : $this->request->getUrl()->getPath(); foreach ($routes as $route) { @@ -200,11 +205,6 @@ class Router */ public function loadRoutes() { - // Stop processing routes if no valid route is found. - if($this->request->getRewriteRoute() === null && $this->request->getUrl() === null) { - return; - } - /* Initialize boot-managers */ /* @var $manager IRouterBootManager */ foreach ($this->bootManagers as $manager) { @@ -365,7 +365,7 @@ class Router } } - throw new HttpException($e->getMessage(), $e->getCode(), $e->getPrevious()); + throw new HttpException($e->getMessage(), (int)$e->getCode(), $e->getPrevious()); } public function arrayToParams(array $getParams = [], $includeEmpty = true)