From 413ece267265e87febc57b6dca6fdd35ac90c13c Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Mon, 5 Sep 2022 08:40:47 +0000
Subject: [PATCH] allow url parameters when no action is given, fixes #1538

Closes #1538

Merge request studip/studip!956
---
 app/controllers/studip_controller.php           | 4 ++--
 tests/unit/lib/classes/StudipControllerTest.php | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/app/controllers/studip_controller.php b/app/controllers/studip_controller.php
index 869d8a9dd05..5e9ab358908 100644
--- a/app/controllers/studip_controller.php
+++ b/app/controllers/studip_controller.php
@@ -257,10 +257,10 @@ abstract class StudipController extends Trails_Controller
 
         // Try to create route if none given
         if ($to === '') {
-            $to = $this->parent_controller
+            $args[0] = $this->parent_controller
                 ? $this->parent_controller->current_action
                 : $this->current_action;
-            return $this->action_url($to);
+            return $this->action_url(...$args);
         }
 
         // Create url for a specific action
diff --git a/tests/unit/lib/classes/StudipControllerTest.php b/tests/unit/lib/classes/StudipControllerTest.php
index 532116677ae..4752ef06af1 100644
--- a/tests/unit/lib/classes/StudipControllerTest.php
+++ b/tests/unit/lib/classes/StudipControllerTest.php
@@ -197,6 +197,7 @@ final class StudipControllerTest extends Codeception\Test\Unit
     {
         return [
             '0-action'                 => ['dispatch.php/studip_controller_test/foo'],
+            '0-action-and-parameter'   => ['dispatch.php/studip_controller_test/foo?bar=42', '', ['bar' => 42]],
             '1-action'                 => ['dispatch.php/foo', 'foo'],
             '1-action-and-parameter'   => ['dispatch.php/foo?bar=42', 'foo', ['bar' => 42]],
             '1-action-and-parameters'  => ['dispatch.php/foo?bar=42&baz=23', 'foo', ['bar' => 42, 'baz' => 23]],
-- 
GitLab