FIX Ensure tmpItem has a value before calling method_exists on it

This commit is contained in:
Steve Boyd 2021-11-25 15:52:51 +13:00
parent 8a73a4ad22
commit a3d9648687

View File

@ -146,7 +146,7 @@ class GridFieldSortableHeader implements GridField_HTMLProvider, GridField_DataM
if ($tmpItem instanceof SS_List) {
// It's impossible to sort on a HasManyList/ManyManyList
break;
} elseif (method_exists($tmpItem, 'hasMethod') && $tmpItem->hasMethod($methodName)) {
} elseif ($tmpItem && method_exists($tmpItem, 'hasMethod') && $tmpItem->hasMethod($methodName)) {
// The part is a relation name, so get the object/list from it
$tmpItem = $tmpItem->$methodName();
} elseif ($tmpItem instanceof DataObject