From a3d964868732d035043f4b1c53dcf2404f119597 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Thu, 25 Nov 2021 15:52:51 +1300 Subject: [PATCH] FIX Ensure tmpItem has a value before calling method_exists on it --- src/Forms/GridField/GridFieldSortableHeader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Forms/GridField/GridFieldSortableHeader.php b/src/Forms/GridField/GridFieldSortableHeader.php index 1cabd8b5e..c9e9e03e5 100644 --- a/src/Forms/GridField/GridFieldSortableHeader.php +++ b/src/Forms/GridField/GridFieldSortableHeader.php @@ -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