From c7b7dc0c2a1ccd8d24e71f1f7a7dd8fb8546bba5 Mon Sep 17 00:00:00 2001 From: Thomas Hackl <hackl@data-quest.de> Date: Wed, 6 Sep 2023 09:38:26 +0000 Subject: [PATCH] Resolve "Fehlermeldungen nach Entfernen der Spalte sem_tree.studip_object_id" Closes #3014 Merge request studip/studip!2016 --- .../5.4.6.1_restore_studip_object_id.php | 26 +++++++++++++++++++ lib/classes/StudipSemTree.class.php | 12 +++------ lib/dbviews/sem_tree.view.php | 4 +-- 3 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 db/migrations/5.4.6.1_restore_studip_object_id.php diff --git a/db/migrations/5.4.6.1_restore_studip_object_id.php b/db/migrations/5.4.6.1_restore_studip_object_id.php new file mode 100644 index 00000000000..b79b93344c5 --- /dev/null +++ b/db/migrations/5.4.6.1_restore_studip_object_id.php @@ -0,0 +1,26 @@ +<? + +final class RestoreStudipObjectId extends Migration +{ + + public function description() + { + return 'Restores the studip_object_id column for sem_tree'; + } + + protected function up() + { + // Add database column for sem_tree institute assignments. + DBManager::get()->exec("ALTER TABLE `sem_tree` ADD + `studip_object_id` CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin NULL DEFAULT NULL AFTER `name`"); + // Add index for studip_object_id. + DBManager::get()->exec("ALTER TABLE `sem_tree` ADD INDEX `studip_object_id` (`studip_object_id`)"); + } + + protected function down() + { + // Remove institute assignments for sem_tree entries. + DBManager::get()->exec("ALTER TABLE `sem_tree` DROP `studip_object_id`"); + } + +} diff --git a/lib/classes/StudipSemTree.class.php b/lib/classes/StudipSemTree.class.php index 203bec15e38..70743ade9a7 100644 --- a/lib/classes/StudipSemTree.class.php +++ b/lib/classes/StudipSemTree.class.php @@ -76,12 +76,8 @@ class StudipSemTree extends TreeAbstract $db = $this->view->get_query("view:SEM_TREE_GET_DATA_NO_ENTRIES"); while ($db->next_record()){ - $this->tree_data[$db->f("sem_tree_id")] = ['type' => $db->f('type'), "info" => $db->f("info"),"studip_object_id" => $db->f("studip_object_id"), "entries" => 0]; - if ($db->f("studip_object_id")){ - $name = $db->f("studip_object_name"); - } else { - $name = $db->f("name"); - } + $this->tree_data[$db->f("sem_tree_id")] = ['type' => $db->f('type'), "info" => $db->f("info"), "entries" => 0]; + $name = $db->f("name"); $this->storeItem($db->f("sem_tree_id"), $db->f("parent_id"), $name, $db->f("priority")); } } @@ -205,10 +201,8 @@ class StudipSemTree extends TreeAbstract if ($item_id == "root") return "root"; $ret_id = $item_id; - while (!$this->tree_data[$ret_id]['studip_object_id']){ + while ($ret_id != "root"){ $ret_id = $this->tree_data[$ret_id]['parent_id']; - if ($ret_id == "root") - break; } return $ret_id; } diff --git a/lib/dbviews/sem_tree.view.php b/lib/dbviews/sem_tree.view.php index f82767dd1eb..008ee933b0c 100644 --- a/lib/dbviews/sem_tree.view.php +++ b/lib/dbviews/sem_tree.view.php @@ -36,8 +36,8 @@ $_views['sem_number_sql'] = "INTERVAL(start_time," . join(",",$sem_start_times) $_views['sem_number_end_sql'] = "IF(duration_time=-1,-1,INTERVAL(start_time+duration_time," . join(",",$sem_start_times) ."))"; $_views["SEM_TREE_GET_DATA_NO_ENTRIES"] = ["pk"=>"sem_tree_id","temp_table_type"=>"HEAP", - "query"=>"SELECT a.*, c.Name AS studip_object_name - FROM sem_tree a LEFT JOIN Institute c ON (a.studip_object_id = c.Institut_id) + "query"=>"SELECT a.* + FROM sem_tree a ORDER BY priority"]; $_views["SEM_TREE_GET_ENTRIES"] = ["pk"=>"sem_tree_id","temp_table_type"=>"HEAP", "query" => "SELECT st.sem_tree_id, count(b.Seminar_id) AS entries -- GitLab