@@ -142,7 +142,6 @@ public function upgrade(Migration $migration, $args = []): bool {
142
142
// Check schema of tables before upgrading
143
143
if (!isset ($ args ['skip-db-check ' ])) {
144
144
$ oldVersion = Config::getConfigurationValue ('formcreator ' , 'previous_version ' );
145
- $ log = '' ;
146
145
if ($ oldVersion !== null ) {
147
146
$ checkResult = true ;
148
147
if (version_compare ($ oldVersion , '2.13.0 ' ) >= 0 ) {
@@ -154,43 +153,29 @@ public function upgrade(Migration $migration, $args = []): bool {
154
153
false ,
155
154
false ,
156
155
false ,
157
- false ,
158
- $ log
156
+ false
159
157
);
160
- } else {
161
- // Upgrading from GLPI 9.5 to GLPI 10
162
- // check only columns format
163
- // $checkResult = $this->checkSchema(
164
- // $oldVersion,
165
- // true,
166
- // false,
167
- // false,
168
- // true,
169
- // true,
170
- // true,
171
- // $log
172
- // );
173
158
}
174
159
if (!$ checkResult ) {
160
+ $ message = sprintf (
161
+ __ ('The database schema is not consistent with the installed Formcreator %s. To see the logs run the command %s ' , 'formcreator ' ),
162
+ $ oldVersion ,
163
+ 'bin/console glpi:plugin:install formcreator -f '
164
+ );
175
165
if (!isCommandLine ()) {
176
- Session::addMessageAfterRedirect (sprintf (
177
- __ ('The database schema is not consistent with the installed Formcreator %s. To see the logs run the command %s ' , 'formcreator ' ),
178
- $ oldVersion ,
179
- 'bin/console glpi:plugin:install formcreator '
180
- ), false , ERROR );
166
+ Session::addMessageAfterRedirect ($ message , false , ERROR );
181
167
} else {
168
+ echo $ message . PHP_EOL ;
169
+ // echo 'Some tables have an incorrect schema. Please review them in the above log.' . PHP_EOL;
170
+ // echo 'Some of those errors are handled in the upgrade step from 2.12.5 to 2.13.0. ' . PHP_EOL;
171
+ // echo 'Please _take a snapshot of your complete database_, then try to run the upgrade with the following command: ' . PHP_EOL;
172
+ // echo 'bin/console glpi:plugin:install formcreator -f -p skip-db-check' . PHP_EOL;
173
+ // echo 'The upgrade procedure will try to solve known errors before upgrading the tables to 2.13.0 version.' . PHP_EOL;
174
+ // echo 'Finally a check of the tables will be executed to report unhandled inconsistencies.' . PHP_EOL;
182
175
echo sprintf (
183
- __ ('The database schema is not consistent with the installed Formcreator %s. To see the logs run the command %s ' , 'formcreator ' ),
184
- $ oldVersion ,
185
- 'bin/console glpi:plugin:install formcreator '
176
+ __ ('To ignore the inconsistencies and upgrade anyway run %s ' , 'formcreator ' ),
177
+ 'bin/console glpi:plugin:install formcreator -f -p skip-db-check '
186
178
) . PHP_EOL ;
187
- echo $ log . PHP_EOL ;
188
- echo 'Some tables have an incorrect schema. Please review them in the above log. ' . PHP_EOL ;
189
- echo 'Some of those errors are handled in the upgrade step from 2.12.5 to 2.13.0. ' . PHP_EOL ;
190
- echo 'Please _take a snapshot of your complete database_, then try to run the upgrade with the following command: ' . PHP_EOL ;
191
- echo 'bin/console glpi:plugin:install formcreator -f -p skip-db-check ' . PHP_EOL ;
192
- echo 'The upgrade procedure will try to solve known errors before upgrading the tables to 2.13.0 version. ' . PHP_EOL ;
193
- echo 'Finally a check of the tables will be executed to report unhandled inconsistencies. ' . PHP_EOL ;
194
179
}
195
180
return false ;
196
181
}
@@ -241,31 +226,25 @@ public function upgrade(Migration $migration, $args = []): bool {
241
226
}
242
227
243
228
// Check schema of tables after upgrade
244
- $ log = '' ;
245
229
$ checkResult = $ this ->checkSchema (
246
230
PLUGIN_FORMCREATOR_VERSION ,
247
- true ,
248
231
false ,
249
232
false ,
250
233
false ,
251
234
false ,
252
235
false ,
253
- $ log
236
+ false
254
237
);
255
238
if (!$ checkResult ) {
239
+ $ message = sprintf (
240
+ __ ('The database schema is not consistent with the installed Formcreator %s. To see the logs enable the plugin and run the command %s ' , 'formcreator ' ),
241
+ PLUGIN_FORMCREATOR_VERSION ,
242
+ 'bin/console glpi:database:check_schema_integrity -p formcreator '
243
+ );
256
244
if (!isCommandLine ()) {
257
- Session::addMessageAfterRedirect (sprintf (
258
- __ ('The database schema is not consistent with the installed Formcreator %s. To see the logs enable the plugin and run the command %s ' , 'formcreator ' ),
259
- PLUGIN_FORMCREATOR_VERSION ,
260
- 'bin/console glpi:database:check_schema_integrity -p formcreator '
261
- ), false , ERROR );
245
+ Session::addMessageAfterRedirect ($ message , false , ERROR );
262
246
} else {
263
- echo sprintf (
264
- __ ('The database schema is not consistent with the installed Formcreator %s. To see the logs run the command %s ' , 'formcreator ' ),
265
- PLUGIN_FORMCREATOR_VERSION ,
266
- 'bin/console glpi:database:check_schema_integrity -p formcreator '
267
- ) . PHP_EOL ;
268
- echo $ log . PHP_EOL ;
247
+ echo $ message . PHP_EOL ;
269
248
}
270
249
}
271
250
@@ -836,8 +815,8 @@ public function checkSchema(
836
815
bool $ ignore_timestamps_migration = false ,
837
816
bool $ ignore_utf8mb4_migration = false ,
838
817
bool $ ignore_dynamic_row_format_migration = false ,
839
- bool $ ignore_unsigned_keys_migration = false ,
840
- string & $ log = '' ): bool {
818
+ bool $ ignore_unsigned_keys_migration = false
819
+ ): bool {
841
820
global $ DB ;
842
821
843
822
$ schemaFile = plugin_formcreator_getSchemaPath ($ version );
@@ -865,25 +844,6 @@ public function checkSchema(
865
844
}
866
845
867
846
if (count ($ differences ) > 0 ) {
868
- if (isCommandLine ()) {
869
- foreach ($ differences as $ table_name => $ difference ) {
870
- $ message = null ;
871
- switch ($ difference ['type ' ]) {
872
- case DatabaseSchemaIntegrityChecker::RESULT_TYPE_ALTERED_TABLE :
873
- $ message = sprintf (__ ('Table schema differs for table "%s". ' ), $ table_name );
874
- break ;
875
- case DatabaseSchemaIntegrityChecker::RESULT_TYPE_MISSING_TABLE :
876
- $ message = sprintf (__ ('Table "%s" is missing. ' ), $ table_name );
877
- break ;
878
- case DatabaseSchemaIntegrityChecker::RESULT_TYPE_UNKNOWN_TABLE :
879
- $ message = sprintf (__ ('Unknown table "%s" has been found in database. ' ), $ table_name );
880
- break ;
881
- }
882
- $ log .= $ message . PHP_EOL ;
883
- $ log .= $ difference ['diff ' ] . PHP_EOL ;
884
- }
885
- }
886
-
887
847
return false ;
888
848
}
889
849
0 commit comments