Skip to content

Commit

Permalink
Update Util.php
Browse files Browse the repository at this point in the history
bugfix:
- in reverse rewrite: if $language is provided, it should not be stripped of $_GET params
  • Loading branch information
christopheg authored Mar 1, 2022
1 parent d6580ca commit c78cc2e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/Skeleton/Core/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit c78cc2e

Please sign in to comment.