ENH Throw exception if empty parent CMSEditLink#1408
ENH Throw exception if empty parent CMSEditLink#1408emteknetnz wants to merge 1 commit intosilverstripe:6from
Conversation
There was a problem hiding this comment.
With the exception in that spot, it will be thrown for any of these public method calls:
getCMSEditLink()getEditLink()getBlockSchema()
That will happen no matter why they're called, and regardless of whether there even is a parent record for the block at the time of the call.
Probably the exception should be thrown from ElementalAreaController or some other place that's closer to the place where the link is actually needed.
Please also use LogicException instead of RuntimeException: https://www.php.net/manual/en/class.logicexception.php
Exception that represents error in the program logic. This kind of exception should lead directly to a fix in your code.
|
Thinking more about this actually - there's some edge cases we need to square away as well. For example what if you move a block to a new parent, but that new parent doesn't have a edit link? Suddenly we're throwing an exception so the elemental area probably won't load. You can't really catch that at dev time. I know I originally suggested an exception but perhaps it would be better to instead do a combination of logging an error, and displaying an error on the block. That way we don't have to consider every possible edge case, and content authors won't have elemental areas failing to load. |
|
Closing for now as the attached card was moved to refinement |
Issue #1407
Requires PRs in #1405 to be merged and merged up for behat to pass