@@ -205,7 +205,7 @@ public function validateSortField(SS_List $list)
205205 if ($ list instanceof ManyManyList) {
206206 $ extra = $ list ->getExtraFields ();
207207
208- if ($ extra && array_key_exists ($ field , $ extra )) {
208+ if ($ extra && array_key_exists ($ field , $ extra ?? [] )) {
209209 return ;
210210 }
211211 } elseif ($ list instanceof ManyManyThroughList) {
@@ -239,7 +239,7 @@ public function getSortTable(SS_List $list)
239239 if ($ list instanceof ManyManyList) {
240240 $ extra = $ list ->getExtraFields ();
241241 $ table = $ list ->getJoinTable ();
242- if ($ extra && array_key_exists ($ field , $ extra )) {
242+ if ($ extra && array_key_exists ($ field , $ extra ?? [] )) {
243243 return $ table ;
244244 }
245245 } elseif ($ list instanceof ManyManyThroughList) {
@@ -277,8 +277,8 @@ public function getHTMLFragments($field)
277277
278278 public function augmentColumns ($ grid , &$ cols )
279279 {
280- if (!in_array ('Reorder ' , $ cols ) && $ grid ->getState ()->GridFieldOrderableRows ->enabled ) {
281- array_splice ($ cols , $ this ->reorderColumnNumber , 0 , 'Reorder ' );
280+ if (!in_array ('Reorder ' , $ cols ?? [] ) && $ grid ->getState ()->GridFieldOrderableRows ->enabled ) {
281+ array_splice ($ cols , $ this ->reorderColumnNumber ?? 0 , 0 , 'Reorder ' );
282282 }
283283 }
284284
@@ -308,7 +308,7 @@ public function getColumnContent($grid, $record, $col)
308308 // if it exists, not directly from the record
309309 $ throughListSorts = $ this ->getSortValuesFromManyManyThroughList ($ list , $ this ->getSortField ());
310310
311- if (array_key_exists ($ record ->ID , $ throughListSorts )) {
311+ if (array_key_exists ($ record ->ID , $ throughListSorts ?? [] )) {
312312 $ currentSortValue = $ throughListSorts [$ record ->ID ];
313313 }
314314 }
@@ -408,8 +408,8 @@ public function handleReorder($grid, $request)
408408
409409 // Get records from the `GridFieldEditableColumns` column
410410 $ gridFieldName = $ grid ->getName ();
411- if (strpos ($ gridFieldName , '. ' ) !== false ) {
412- $ gridFieldName = str_replace ('. ' , '_ ' , $ gridFieldName );
411+ if (strpos ($ gridFieldName ?? '' , '. ' ) !== false ) {
412+ $ gridFieldName = str_replace ('. ' , '_ ' , $ gridFieldName ?? '' );
413413 }
414414
415415 $ data = $ request ->postVar ($ gridFieldName );
@@ -549,7 +549,7 @@ protected function executeReorder(GridField $grid, $sortedIDs)
549549 $ items = $ list ->filter ('ID ' , $ sortedIDs )->sort ($ sortterm );
550550
551551 // Ensure that each provided ID corresponded to an actual object.
552- if (count ($ items ) != count ($ sortedIDs )) {
552+ if (count ($ items ?? [] ) != count ($ sortedIDs ?? [] )) {
553553 return false ;
554554 }
555555
@@ -720,7 +720,7 @@ protected function populateSortValues(DataList $list)
720720 protected function getSortTableClauseForIds (DataList $ list , $ ids )
721721 {
722722 if (is_array ($ ids )) {
723- $ value = 'IN ( ' . implode (', ' , array_map ('intval ' , $ ids )) . ') ' ;
723+ $ value = 'IN ( ' . implode (', ' , array_map ('intval ' , $ ids ?? [] )) . ') ' ;
724724 } else {
725725 $ value = '= ' . (int ) $ ids ;
726726 }
@@ -734,7 +734,7 @@ protected function getSortTableClauseForIds(DataList $list, $ids)
734734 $ foreignKey = $ this ->getManyManyInspectorForeignKey ($ introspector );
735735 $ foreignID = (int ) $ list ->getForeignID ();
736736
737- if ($ extra && array_key_exists ($ this ->getSortField (), $ extra )) {
737+ if ($ extra && array_key_exists ($ this ->getSortField (), $ extra ?? [] )) {
738738 return sprintf (
739739 '"%s" %s AND "%s" = %d ' ,
740740 $ key ,
0 commit comments