Skip to content

Commit 490af18

Browse files
committed
fix(install): repair possible inconsistent root entity config
1 parent 477b5f1 commit 490af18

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

install/upgrade_to_2.13.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class PluginFormcreatorUpgradeTo2_13 {
3838
public function upgrade(Migration $migration) {
3939
$this->migration = $migration;
4040
$this->migrateEntityConfig();
41+
$this->fixRootEntityConfig();
4142
$this->migrateFkToUnsignedInt();
4243
$this->addFormAnswerTitle();
4344
$this->defaultValuesForTargets();
@@ -152,6 +153,26 @@ protected function migrateEntityConfig() {
152153
$DB->queryOrDie("UPDATE `$table` SET `entities_id`=`id`");
153154
}
154155

156+
/**
157+
* Fix possible invalid root entity config
158+
*
159+
* @return void
160+
*/
161+
private function fixRootEntityConfig() {
162+
global $DB;
163+
164+
$table = 'glpi_plugin_formcreator_entityconfigs';
165+
$DB->update($table, [
166+
'replace_helpdesk' => new QueryExpression("IF(`replace_helpdesk` = -2, 0, `replace_helpdesk`)"),
167+
'sort_order' => new QueryExpression("IF(`sort_order` = -2, 0, `sort_order`)"),
168+
'is_kb_separated' => new QueryExpression("IF(`is_kb_separated` = -2, 0, `is_kb_separated`)"),
169+
'is_search_visible' => new QueryExpression("IF(`is_search_visible` = -2, 1, `is_search_visible`)"),
170+
'is_header_visible' => new QueryExpression("IF(`is_header_visible` = -2, 1, `is_header_visible`)"),
171+
], [
172+
'entities_id' => 0,
173+
]);
174+
}
175+
155176
protected function migrateFkToUnsignedInt() {
156177
global $DB;
157178

0 commit comments

Comments
 (0)