19 declare(strict_types=1);
34 return "Migration of glossary definitions after abolition of multiple definitions";
39 return Migration::INFINITE;
53 $this->db = $environment->
getResource(Environment::RESOURCE_DATABASE);
58 $set = $this->db->query(
59 "SELECT glossary_definition.id AS glo_def_id, glossary_definition.term_id AS glo_def_term_id, " .
60 " glossary_definition.short_text, glossary_definition.short_text_dirty, " .
61 " glossary_term.id AS glo_term_id, glossary_term.glo_id, glossary_term.term, glossary_term.language, " .
62 " glossary_term.create_date, glossary_term.last_update " .
63 " FROM glossary_definition JOIN glossary_term " .
64 " WHERE glossary_definition.term_id = glossary_term.id " .
65 " ORDER BY glossary_term.glo_id, glossary_term.id, glossary_definition.id" 68 while ($rec = $this->db->fetchAssoc($set)) {
71 && $tmp[
"glo_id"] == $rec[
"glo_id"]
72 && $tmp[
"glo_term_id"] == $rec[
"glo_term_id"]
74 $new_term_id = $this->db->nextId(
'glossary_term');
76 $this->
log(
"Create new glossary term with id: " . $new_term_id);
77 $this->db->manipulate(
"INSERT INTO glossary_term (id, glo_id, term, language, import_id, create_date, last_update)" .
79 $this->db->quote($new_term_id,
"integer") .
", " .
80 $this->db->quote($rec[
"glo_id"],
"integer") .
", " .
81 $this->db->quote($rec[
"term"],
"text") .
", " .
82 $this->db->quote($rec[
"language"],
"text") .
"," .
83 $this->db->quote(
"",
"text") .
"," .
84 $this->db->quote($rec[
"create_date"],
"text") .
", " .
85 $this->db->quote($rec[
"last_update"],
"text") .
")");
87 $this->db->manipulate(
88 "UPDATE glossary_definition SET " .
89 " term_id = " . $this->db->quote($new_term_id,
"integer") .
90 " WHERE id = " . $this->db->quote($rec[
"glo_def_id"],
"integer")
93 $tmp[
"glo_id"] = $rec[
"glo_id"];
94 $tmp[
"glo_term_id"] = $rec[
"glo_term_id"];
97 $set = $this->db->query(
"SELECT * FROM glossary_definition WHERE migration = " . $this->db->quote(
"0",
"integer"));
98 while ($rec = $this->db->fetchAssoc($set)) {
100 $this->
log(
"Add short text ('" . $rec[
"short_text"] .
"') and short text dirty ('" .
101 $rec[
"short_text_dirty"] .
"') to glossary term with id: " . $rec[
"term_id"]);
102 $this->db->manipulate(
103 "UPDATE glossary_term SET " .
104 " short_text = " . $this->db->quote($rec[
"short_text"],
"text") .
", " .
105 " short_text_dirty = " . $this->db->quote($rec[
"short_text_dirty"],
"integer") .
106 " WHERE id = " . $this->db->quote($rec[
"term_id"],
"integer")
109 $this->
log(
"Update id and type ('gdf' to 'term') for page object with id: " . $rec[
"id"]);
110 $this->db->manipulate(
111 "UPDATE page_object SET " .
112 " page_id = " . $this->db->quote($rec[
"term_id"],
"integer") .
", " .
113 " parent_type = " . $this->db->quote(
"term",
"text") .
114 " WHERE parent_type = " . $this->db->quote(
"gdf",
"text") .
115 " AND page_id = " . $this->db->quote($rec[
"id"],
"integer")
118 $this->db->manipulate(
119 "UPDATE glossary_definition SET " .
120 " migration = " . $this->db->quote(
"1",
"integer") .
121 " WHERE id = " . $this->db->quote($rec[
"id"],
"integer")
126 $this->
log(
"Update type ('gdf' to 'term') for page object definition.");
127 $this->db->manipulate(
128 "UPDATE copg_pobj_def SET " .
129 " parent_type = " . $this->db->quote(
"term",
"text") .
130 " WHERE parent_type = " . $this->db->quote(
"gdf",
"text")
134 protected function log(
string $str): void
141 $this->db->manipulate($query);
147 $set = $this->db->query(
148 "SELECT glossary_definition.id AS glo_def_id, glossary_definition.term_id AS glo_def_term_id, " .
149 " glossary_definition.short_text, glossary_definition.short_text_dirty, " .
150 " glossary_term.id AS glo_term_id, glossary_term.glo_id, glossary_term.term, glossary_term.language, " .
151 " glossary_term.create_date, glossary_term.last_update " .
152 " FROM glossary_definition JOIN glossary_term " .
153 " WHERE glossary_definition.term_id = glossary_term.id " .
154 " ORDER BY glossary_term.glo_id, glossary_term.id, glossary_definition.id" 157 while ($rec = $this->db->fetchAssoc($set)) {
160 && $tmp[
"glo_id"] == $rec[
"glo_id"]
161 && $tmp[
"glo_term_id"] == $rec[
"glo_term_id"]
165 $tmp[
"glo_id"] = $rec[
"glo_id"];
166 $tmp[
"glo_term_id"] = $rec[
"glo_term_id"];
169 $set = $this->db->query(
"SELECT * FROM glossary_definition WHERE migration = " . $this->db->quote(
"0",
"integer"));
170 if ($rec = $this->db->fetchAssoc($set)) {
174 $set = $this->db->query(
"SELECT parent_type FROM copg_pobj_def WHERE parent_type = " . $this->db->quote(
"gdf",
"text"));
175 if ($rec = $this->db->fetchAssoc($set)) {
getPreconditions(Environment $environment)
manipulate(string $query)
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
prepare(Environment $environment)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.
step(Environment $environment)
getRemainingAmountOfSteps()
getDefaultAmountOfStepsPerRun()