From f12fa62ad60e643bb93cc191f77cc75404b6a25c Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Mon, 8 Apr 2019 18:09:51 +1200 Subject: [PATCH] FIX: Better error message when GridFieldLevelup passed bad record details Fixes https://github.com/silverstripe/silverstripe-framework/issues/3519 --- src/Forms/GridField/GridFieldLevelup.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Forms/GridField/GridFieldLevelup.php b/src/Forms/GridField/GridFieldLevelup.php index 84d92af19..6e653ee76 100644 --- a/src/Forms/GridField/GridFieldLevelup.php +++ b/src/Forms/GridField/GridFieldLevelup.php @@ -62,6 +62,11 @@ class GridFieldLevelup implements GridField_HTMLProvider /** @var DataObject|Hierarchy $modelObj */ $modelObj = DataObject::get_by_id($modelClass, $this->currentID); + if (!$modelObj) { + throw new \LogicException( + "Can't find object of class $modelClass ID #{$this->currentID} for GridFieldLevelup" + ); + } $parent = null; if ($modelObj->hasMethod('getParent')) {