ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilWikiDBUpdateSteps.php
Go to the documentation of this file.
1 <?php
2 
19 namespace ILIAS\Wiki\Setup;
20 
25 {
26  protected \ilDBInterface $db;
27 
28  public function prepare(\ilDBInterface $db): void
29  {
30  $this->db = $db;
31  }
32 
33  public function step_1(): void
34  {
35  $db = $this->db;
36  foreach (["int_links", "ext_links", "footnotes", "num_ratings", "num_words", "avg_rating", "deleted"] as $field) {
37  $db->modifyTableColumn('wiki_stat_page', $field, array(
38  'type' => 'integer',
39  'length' => 4,
40  'notnull' => true,
41  'default' => 0
42  ));
43  }
44  }
45 
46  public function step_2(): void
47  {
48  $db = $this->db;
49  foreach (["num_chars"] as $field) {
50  $db->modifyTableColumn('wiki_stat_page', $field, array(
51  'type' => 'integer',
52  'length' => 8,
53  'notnull' => true,
54  'default' => 0
55  ));
56  }
57  }
58 
59  public function step_3(): void
60  {
61  $db = $this->db;
62  foreach (["num_pages", "del_pages", "avg_rating"] as $field) {
63  $db->modifyTableColumn('wiki_stat', $field, array(
64  'type' => 'integer',
65  'length' => 4,
66  'notnull' => true,
67  'default' => 0
68  ));
69  }
70  }
71 
72  public function step_4(): void
73  {
74  $db = $this->db;
75  if (!$db->tableColumnExists('il_wiki_page', 'lang')) {
76  $this->db->addTableColumn('il_wiki_page', 'lang', array(
77  'type' => 'text',
78  'notnull' => true,
79  'length' => 10,
80  'default' => "-"
81  ));
82  $this->db->dropPrimaryKey('il_wiki_page');
83  $this->db->addPrimaryKey(
84  'il_wiki_page',
85  ["id", "lang"]
86  );
87  }
88  }
89 
90  public function step_5(): void
91  {
92  $db = $this->db;
93  if (!$db->tableColumnExists('il_wiki_missing_page', 'lang')) {
94  $this->db->addTableColumn('il_wiki_missing_page', 'lang', array(
95  'type' => 'text',
96  'notnull' => true,
97  'length' => 5,
98  'default' => "-"
99  ));
100  $this->db->dropPrimaryKey('il_wiki_missing_page');
101  $this->db->addPrimaryKey(
102  'il_wiki_missing_page',
103  ["wiki_id", "source_id", "target_name", "lang"]
104  );
105  }
106  }
107 
108  public function step_6(): void
109  {
110  $db = $this->db;
111  $set = $db->queryF(
112  "SELECT * FROM il_wiki_data " .
113  " WHERE public_notes = %s ",
114  ["integer"],
115  [1]
116  );
117  while ($rec = $db->fetchAssoc($set)) {
118  $set2 = $db->queryF(
119  "SELECT * FROM note_settings " .
120  " WHERE rep_obj_id = %s AND obj_id = %s",
121  ["integer", "integer"],
122  [$rec["id"], 0]
123  );
124  if ($rec2 = $db->fetchAssoc($set2)) {
125  $db->update(
126  "note_settings",
127  [
128  "activated" => ["integer", 1]
129  ],
130  [ // where
131  "rep_obj_id" => ["integer", $rec["id"]],
132  "obj_id" => ["integer", 0]
133  ]
134  );
135  } else {
136  $db->insert("note_settings", [
137  "rep_obj_id" => ["integer", $rec["id"]],
138  "obj_id" => ["integer", 0],
139  "activated" => ["integer", 1],
140  "obj_type" => ["text", "wiki"]
141  ]);
142  }
143  }
144 
145  }
146 
147 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
modifyTableColumn(string $table, string $column, array $attributes)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addTableColumn(string $table_name, string $column_name, array $attributes)
queryF(string $query, array $types, array $values)
prepare(\ilDBInterface $db)
Prepare the execution of the steps.