diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 4c99f96..5f83fea 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -543,11 +543,15 @@ function comment_entity_view(EntityInterface $entity, EntityViewDisplayInterface } } } - elseif ($view_mode != 'search_index' && $view_mode != 'search_result' && $view_mode != 'print') { + elseif ($view_mode == 'search_index' || $view_mode == 'search_result' || $view_mode == 'print') { + // We don't want this link if we're building the entity for: + // - search indexing + // - constructing a search result excerpt. + // - print + } + else { // Entity in other view modes: add a "post comment" link if the user is // allowed to post comments and if this entity is allowing new comments. - // But we don't want this link if we're building the entity for search - // indexing or constructing a search result excerpt. if ($commenting_status == COMMENT_OPEN) { $comment_form_location = $instance->getSetting('form_location'); if (user_access('post comments')) { 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 3cc4906..5b4ccc2 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 @@ -116,7 +116,7 @@ class CommentDefaultFormatter extends FormatterBase implements ContainerFactoryP // Comments are added to the search results and search index by // comment_node_update_index() instead of by this formatter, so don't // return anything if the view mode is search_index or search_result. - !in_array($this->viewMode, array('search_result', 'search_index', 'print'))) { + !in_array($this->viewMode, array('search_result', 'search_index'))) { $comment_settings = $this->getFieldSettings(); // Only attempt to render comments if the entity has visible comments.