@@ -193,6 +193,16 @@ public function safeUp()
193
193
$ superTableField = $ fieldsService ->getFieldById ($ superTableBlockType ['fieldId ' ]);
194
194
$ fieldLayout = $ fieldsService ->getLayoutById ($ superTableBlockType ['fieldLayoutId ' ]);
195
195
196
+ if (!$ superTableField ) {
197
+ echo " > ERROR: Blocktype field # {$ superTableBlockType ['fieldId ' ]} not found ... \n" ;
198
+ continue ;
199
+ }
200
+
201
+ if (get_class ($ superTableField ) !== SuperTableField::class) {
202
+ echo " > ERROR: Blocktype field # {$ superTableBlockType ['fieldId ' ]} is not a Super Table field ... \n" ;
203
+ continue ;
204
+ }
205
+
196
206
// Find what the columns should be according to the block type fields
197
207
if ($ fieldLayout ) {
198
208
foreach ($ fieldLayout ->getFields () as $ field ) {
@@ -216,27 +226,25 @@ public function safeUp()
216
226
}
217
227
218
228
if ($ superTableField ) {
219
- if (get_class ($ superTableField ) == SuperTableField::class) {
220
- $ contentTable = $ superTableField ->contentTable ;
229
+ $ contentTable = $ superTableField ->contentTable ;
221
230
222
- if ($ contentTable ) {
223
- $ columns = $ this ->db ->getTableSchema ($ contentTable )->columns ;
231
+ if ($ contentTable ) {
232
+ $ columns = $ this ->db ->getTableSchema ($ contentTable )->columns ;
224
233
225
- foreach ($ columns as $ key => $ column ) {
226
- if (strstr ($ key , 'field_ ' )) {
227
- $ dbFieldColumns [] = $ key ;
228
- }
234
+ foreach ($ columns as $ key => $ column ) {
235
+ if (strstr ($ key , 'field_ ' )) {
236
+ $ dbFieldColumns [] = $ key ;
229
237
}
238
+ }
230
239
231
- // Sort items the same - just in case they're in a slightly different order, but all there
232
- sort ($ correctFieldColumns );
233
- sort ($ dbFieldColumns );
240
+ // Sort items the same - just in case they're in a slightly different order, but all there
241
+ sort ($ correctFieldColumns );
242
+ sort ($ dbFieldColumns );
234
243
235
- if ($ correctFieldColumns != $ dbFieldColumns ) {
236
- $ fieldsService ->saveField ($ superTableField );
244
+ if ($ correctFieldColumns != $ dbFieldColumns ) {
245
+ $ fieldsService ->saveField ($ superTableField );
237
246
238
- echo " > Content table {$ contentTable } field columns have been corrected ... \n" ;
239
- }
247
+ echo " > Content table {$ contentTable } field columns have been corrected ... \n" ;
240
248
}
241
249
}
242
250
}
0 commit comments