commit 5592579c63352dc395103f03e909dffce0aed0b5 Author: catch Date: Thu Mar 27 15:33:11 2014 +0100 Remove entity from comment reply/preview brute force fixin'. diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 456fec8..195f14a 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1246,28 +1246,10 @@ function comment_preview(CommentInterface $comment, array &$form_state) { $parent = $comment->getParentComment(); if ($parent && $parent->isPublished()) { $build = comment_view($parent); + $preview_build['comment_output_below'] = $build; } } - else { - // The comment field output includes rendering the parent entity of the - // thread to which the comment is a reply. The rendered entity output - // includes the comment reply form, which contains the comment preview and - // therefore the rendered parent entity. This results in an infinite loop of - // parent entity output rendering the comment form and the comment form - // rendering the parent entity. To prevent this infinite loop we temporarily - // set the value of the comment field on the rendered entity to hidden - // before calling entity_view(). That way when the output of the commented - // entity is rendered, it excludes the comment field output. As objects are - // always addressed by reference we ensure changes are not lost by setting - // the value back to its original state after the call to entity_view(). - $field_name = $comment->getFieldName(); - $original_status = $entity->get($field_name)->status; - $entity->get($field_name)->status = CommentItemInterface::HIDDEN; - $build = entity_view($entity, 'full'); - $entity->get($field_name)->status = $original_status; - } - $preview_build['comment_output_below'] = $build; $preview_build['comment_output_below']['#weight'] = 100; return $preview_build; diff --git a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php index 7a4115f..ced6052 100644 --- a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php +++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php @@ -248,17 +248,6 @@ public function getReplyForm(Request $request, $entity_type, $entity_id, $field_ // Display the parent comment. $build['comment_parent'] = $this->entityManager()->getViewBuilder('comment')->view($comment); } - - // The comment is in response to a entity. - elseif ($entity->access('view', $account)) { - // We make sure the field value isn't set so we don't end up with a - // redirect loop. - $entity->{$field_name}->status = CommentItemInterface::HIDDEN; - // Render array of the entity full view mode. - $build['commented_entity'] = $this->entityManager()->getViewBuilder($entity->getEntityTypeId())->view($entity, 'full'); - unset($build['commented_entity']['#cache']); - $entity->{$field_name}->status = $status; - } } else { $build['#title'] = $this->t('Preview comment'); diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php index fbb6ab3..9a71647 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php @@ -211,7 +211,7 @@ public static function renderForm(array $element, array $context) { $entity = entity_load($context['entity_type'], $context['entity_id']); $form = comment_add($entity, $context['field_name']); // @todo: #attached. - $replace = drupal_render($form); + $replace = drupal_render($form, TRUE); $element['#markup'] = str_replace($placeholder, $replace, $element['#markup']); return $element;