From ac92dbb5150681b27ff51ace6f2da4e1f45415b6 Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Mon, 16 Nov 2015 15:35:51 +1300 Subject: [PATCH] Handle when extension has been removed from object When in the admin panel, if parent has been removing from commenting then it won't have the commenting extension attached. --- code/model/Comment.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/model/Comment.php b/code/model/Comment.php index a6d8da1..09e0825 100755 --- a/code/model/Comment.php +++ b/code/model/Comment.php @@ -202,15 +202,17 @@ class Comment extends DataObject { public function getOption($key) { // If possible use the current record $record = $this->getParent(); + if(!$record && $this->BaseClass) { // Otherwise a singleton of that record $record = singleton($this->BaseClass); - } elseif(!$record) { + } + else if(!$record) { // Otherwise just use the default options $record = singleton('CommentsExtension'); } - return $record->getCommentsOption($key); + return ($record->hasMethod('getCommentsOption')) ? $record->getCommentsOption($key) : null; } /**