From c78cc2e393c0f33a8e981b840d2d6bcfda2f432d Mon Sep 17 00:00:00 2001 From: Christophe Gosiau Date: Tue, 1 Mar 2022 16:13:29 +0100 Subject: [PATCH] Update Util.php bugfix: - in reverse rewrite: if $language is provided, it should not be stripped of $_GET params --- lib/Skeleton/Core/Util.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Skeleton/Core/Util.php b/lib/Skeleton/Core/Util.php index 8ebbf2a..6245a04 100644 --- a/lib/Skeleton/Core/Util.php +++ b/lib/Skeleton/Core/Util.php @@ -102,8 +102,10 @@ private static function rewrite_reverse_routes($url_raw) { /** * Add language to the known parameters */ + $language_added = false; if (isset($application->language) AND !isset($params['language'])) { $params['language'] = $application->language->name_short; + $language_added = true; } /** @@ -148,6 +150,7 @@ private static function rewrite_reverse_routes($url_raw) { $route_parts = explode('/', $route); $route_part_matches = 0; $params_matches = 0; + foreach ($route_parts as $key => $route_part) { if (trim($route_part) == '') { unset($route_parts[$key]); @@ -204,7 +207,6 @@ private static function rewrite_reverse_routes($url_raw) { } } - if ($route_part_matches == count($route_parts) AND $route_part_matches > $correct_route_params_matches) { $correct_route = $route_parts; $correct_route_params_matches = $route_part_matches; @@ -230,7 +232,9 @@ private static function rewrite_reverse_routes($url_raw) { /** * Language param was added earlier. Remove it. It should not be included if it was not part of the route */ - unset($params['language']); + if ($language_added) { + unset($params['language']); + } /** * If the first character is a /, remove it