From 2afe784f474975372197d8033dab449eace8dca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sessing=C3=B8?= Date: Sat, 16 Apr 2016 13:08:32 +0200 Subject: [PATCH 1/2] [BUGFIX] Fixed middlewaresToLoad logic used before any routes loaded in RouterBase. --- src/Pecee/SimpleRouter/RouterBase.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Pecee/SimpleRouter/RouterBase.php b/src/Pecee/SimpleRouter/RouterBase.php index 231e6d4..f88be22 100644 --- a/src/Pecee/SimpleRouter/RouterBase.php +++ b/src/Pecee/SimpleRouter/RouterBase.php @@ -111,13 +111,6 @@ class RouterBase { $originalUri = $this->request->getUri(); - // Load group middlewares - - /* @var $middleware RouterEntry */ - foreach($this->middlewaresToLoad as $middleware) { - $middleware->loadMiddleware($this->request); - } - // Initialize boot-managers if(count($this->bootManagers)) { /* @var $manager RouterBootManager */ @@ -138,6 +131,12 @@ class RouterBase { // Loop through each route-request $this->processRoutes($this->routes); + // Load group middlewares + /* @var $route RouterEntry */ + foreach($this->middlewaresToLoad as $route) { + $route->loadMiddleware($this->request); + } + $routeNotAllowed = false; // Make sure routes with longer urls are rendered first @@ -309,7 +308,7 @@ class RouterBase { return ''; } - protected function processUrl($route, $method = null, $parameters = null, $getParams = null) { + protected function processUrl(RouterRoute $route, $method = null, $parameters = null, $getParams = null) { $domain = ''; From eb3ddf2bf7d1b44aa433aad96b5c63fd3a79ae4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sessing=C3=B8?= Date: Sat, 16 Apr 2016 21:34:22 +0200 Subject: [PATCH 2/2] [OPTIMISATION] Optimized get method in Input class to trim value and return default value if empty. --- src/Pecee/Http/Input/Input.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pecee/Http/Input/Input.php b/src/Pecee/Http/Input/Input.php index 475b19c..db45b00 100644 --- a/src/Pecee/Http/Input/Input.php +++ b/src/Pecee/Http/Input/Input.php @@ -89,7 +89,7 @@ class Input { return ($key !== null && isset($item->getValue()[$key])) ? $item->getValue()[$key] : $item->getValue(); } - return ($item->getValue() === null) ? $default : $item->getValue(); + return (trim($item->getValue()) === '') ? $default : $item->getValue(); } return $default;