From e9e12392ac8e2e56e1da5c464fc787e365670895 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Wed, 24 Apr 2019 14:03:55 +0300 Subject: [PATCH] Fixed `$grav['route']` from being modified when the route instance gets modified --- CHANGELOG.md | 6 ++++++ system/src/Grav/Common/Service/RequestServiceProvider.php | 6 +++--- system/src/Grav/Framework/Route/Route.php | 2 ++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bd694330..75a45dd96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.6.9 +## mm/dd/2019 + +1. [](#bugfix) + * Fixed `$grav['route']` from being modified when the route instance gets modified + # v1.6.8 ## 04/23/2019 diff --git a/system/src/Grav/Common/Service/RequestServiceProvider.php b/system/src/Grav/Common/Service/RequestServiceProvider.php index d7b496d86..6410ef725 100644 --- a/system/src/Grav/Common/Service/RequestServiceProvider.php +++ b/system/src/Grav/Common/Service/RequestServiceProvider.php @@ -31,8 +31,8 @@ class RequestServiceProvider implements ServiceProviderInterface return $creator->fromGlobals(); }; - $container['route'] = function() { - return Uri::getCurrentRoute(); - }; + $container['route'] = $container->factory(function() { + return clone Uri::getCurrentRoute(); + }); } } diff --git a/system/src/Grav/Framework/Route/Route.php b/system/src/Grav/Framework/Route/Route.php index f287694c8..481dc4bf8 100644 --- a/system/src/Grav/Framework/Route/Route.php +++ b/system/src/Grav/Framework/Route/Route.php @@ -193,6 +193,7 @@ class Route public function withRoute($route) { $this->route = $route; + return $this; } @@ -205,6 +206,7 @@ class Route public function withRoot($root) { $this->root = $root; + return $this; }