From 450ed93f368c6e5f308e242489e6c534e4d44f7e Mon Sep 17 00:00:00 2001 From: Gordon Anderson Date: Fri, 8 Jan 2016 12:51:14 +0700 Subject: [PATCH] FIX: Change creation of CreatedField to unchained as setName() method of DatetimeField is not chainable --- code/model/Comment.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/code/model/Comment.php b/code/model/Comment.php index 9c301c5..515185b 100755 --- a/code/model/Comment.php +++ b/code/model/Comment.php @@ -202,11 +202,11 @@ 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); - } + } else if(!$record) { // Otherwise just use the default options $record = singleton('CommentsExtension'); @@ -500,7 +500,7 @@ class Comment extends DataObject { $this->write(); $this->extend('afterMarkUnapproved'); } - + /** * @return string */ @@ -570,14 +570,15 @@ class Comment extends DataObject { _t('Comment.ParentComment_Title', 'This comment is a reply to the below') )); // Created date - $fields->push( - $parent - ->obj('Created') - ->scaffoldFormField($parent->fieldLabel('Created')) - ->setName('ParentComment_Created') - ->setValue($parent->Created) - ->performReadonlyTransformation() - ); + // FIXME - the method setName in DatetimeField is not chainable, hence + // the lack of chaining here + $createdField = $parent + ->obj('Created') + ->scaffoldFormField($parent->fieldLabel('Created')); + $createdField->setName('ParentComment_Created'); + $createdField->setValue($parent->Created); + $createdField->performReadonlyTransformation(); + $fields->push($createdField); // Name (could be member or string value) $fields->push( @@ -678,7 +679,7 @@ class Comment extends DataObject { if(!$this->getRepliesEnabled()) { return new ArrayList(); } - + // Get all non-spam comments $order = $this->getOption('order_replies_by') ?: $this->getOption('order_comments_by'); @@ -701,7 +702,7 @@ class Comment extends DataObject { return new ArrayList(); } $list = $this->AllReplies(); - + // Filter spam comments for non-administrators if configured $parent = $this->getParent(); $showSpam = $this->getOption('frontend_spam') && $parent && $parent->canModerateComments();