@@ -38,6 +38,7 @@ class PluginFormcreatorUpgradeTo2_13 {
38
38
public function upgrade (Migration $ migration ) {
39
39
$ this ->migration = $ migration ;
40
40
$ this ->migrateEntityConfig ();
41
+ $ this ->fixRootEntityConfig ();
41
42
$ this ->migrateFkToUnsignedInt ();
42
43
$ this ->addFormAnswerTitle ();
43
44
$ this ->defaultValuesForTargets ();
@@ -152,6 +153,26 @@ protected function migrateEntityConfig() {
152
153
$ DB ->queryOrDie ("UPDATE ` $ table` SET `entities_id`=`id` " );
153
154
}
154
155
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
+
155
176
protected function migrateFkToUnsignedInt () {
156
177
global $ DB ;
157
178
0 commit comments