From e4b3afa3c7ce3667d40ddee09db4b9fd41fad4b5 Mon Sep 17 00:00:00 2001
From: David Siegfried <david.siegfried@uni-vechta.de>
Date: Sat, 15 Jul 2023 18:20:04 +0000
Subject: [PATCH] fix sql, closes #2870

Closes #2870

Merge request studip/studip!1941
---
 lib/models/StudipStudyArea.class.php | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/lib/models/StudipStudyArea.class.php b/lib/models/StudipStudyArea.class.php
index 2975fb4b70c..877b5a86396 100644
--- a/lib/models/StudipStudyArea.class.php
+++ b/lib/models/StudipStudyArea.class.php
@@ -358,21 +358,16 @@ class StudipStudyArea extends SimpleORMap implements StudipTreeNode
     /**
      * Search for study areas whose name matches the given search term.
      *
-     * @param  string     the seach term
+     * @param string $searchTerm the seach term
      *
-     * @return type       <description>
+     * @return StudipStudyArea[] nodes
      */
     public static function search($searchTerm)
     {
-        $query =
-        "sem_tree_id IN (
-        SELECT sem_tree_id FROM sem_tree st1 WHERE name LIKE :searchTerm
-        UNION DISTINCT
-        SELECT sem_tree_id FROM Institute i
-        INNER JOIN sem_tree st2 ON st2.studip_object_id = i.Institut_id
-        WHERE i.Name LIKE :searchTerm )
-        ORDER BY priority";
-        return self::findBySql($query, ['searchTerm' => "%$searchTerm%"]);
+        return self::findBySql(
+            "sem_tree_id IN (SELECT sem_tree_id FROM sem_tree WHERE name LIKE :searchTerm ORDER BY priority)",
+            ['searchTerm' => "%$searchTerm%"]
+        );
     }
 
     /**
-- 
GitLab