-
Notifications
You must be signed in to change notification settings - Fork 821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GRIDFIELD] GridFieldLevelup - Exception thrown #3519
Comments
Hi @phptek |
@whovianguitarist not off the top of my head, but hopefully you can see how a No result would be found if for some reason Also, I hope that helps, but sorry, I don't recall the specific stack trace that I based this bug report from. |
We should definitely be coding defensively to stop this happening, I agree. But you should also look into why you're having this problem. The patch you suggest would be perfectly find and I would welcome a PR to that effect. |
Just something like this? diff --git a/src/Forms/GridField/GridFieldLevelup.php b/src/Forms/GridField/GridFieldLevelup.php
index 84d92af19..2268644bc 100644
--- a/src/Forms/GridField/GridFieldLevelup.php
+++ b/src/Forms/GridField/GridFieldLevelup.php
@@ -62,6 +62,9 @@ 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}");
+ }
$parent = null;
if ($modelObj->hasMethod('getParent')) { Will PR it... |
Using Raygun on our project has really given us more insight into errors that may ordinarily go unoticed, the following is a good example:
In
GridFieldLevelup->getHTMLFragments()
there is some bad condition checking, which should be beefed-up. The project in question is way too busy for me to consider a patch and writing tests for it, but consider the folliowing a "gist":Consider rewriting to something like this (or use an early return)
The Raygun exception is as follows:
The text was updated successfully, but these errors were encountered: