diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 155a6b6..5ae00d1 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -718,46 +718,8 @@ function template_preprocess_comment(&$variables) { $variables['permalink'] = \Drupal::l(t('Permalink'), $comment->permalink()); } - $variables['submitted'] = t('Submitted by @username on @datetime', array('@username' => $variables['author'], '@datetime' => $variables['created'])); - if ($comment->hasParentComment()) { - // Fetch and store the parent comment information for use in templates. - $comment_parent = $comment->getParentComment(); - $account_parent = comment_prepare_author($comment_parent); - $variables['parent_comment'] = $comment_parent; - $username = array( - '#theme' => 'username', - '#account' => $account_parent, - ); - $variables['parent_author'] = drupal_render($username); - $variables['parent_created'] = format_date($comment_parent->getCreatedTime()); - // Avoid calling format_date() twice on the same timestamp. - if ($comment_parent->getChangedTime() == $comment_parent->getCreatedTime()) { - $variables['parent_changed'] = $variables['parent_created']; - } - else { - $variables['parent_changed'] = format_date($comment_parent->getChangedTime()); - } - $permalink_uri_parent = $comment_parent->permalink(); - $attributes = $permalink_uri_parent->getOption('attributes') ?: array(); - $attributes += array('class' => array('permalink'), 'rel' => 'bookmark'); - $permalink_uri_parent->setOption('attributes', $attributes); - $variables['parent_title'] = \Drupal::l($comment_parent->getSubject(), $permalink_uri_parent); - $variables['parent_permalink'] = \Drupal::l(t('Parent permalink'), $permalink_uri_parent); - $variables['parent'] = t('In reply to !parent_title by !parent_username', - array('!parent_username' => $variables['parent_author'], '!parent_title' => $variables['parent_title'])); - } - else { - $variables['parent_comment'] = ''; - $variables['parent_author'] = ''; - $variables['parent_created'] = ''; - $variables['parent_changed'] = ''; - $variables['parent_title'] = ''; - $variables['parent_permalink'] = ''; - $variables['parent'] = ''; - } - // Helpful $content variable for templates. foreach (Element::children($variables['elements']) as $key) { $variables['content'][$key] = $variables['elements'][$key]; diff --git a/core/modules/comment/src/Entity/Comment.php b/core/modules/comment/src/Entity/Comment.php index 909abc3..930dc57 100644 --- a/core/modules/comment/src/Entity/Comment.php +++ b/core/modules/comment/src/Entity/Comment.php @@ -333,6 +333,7 @@ public static function bundleFieldDefinitions(EntityTypeInterface $entity_type, * {@inheritdoc} */ public function hasParentComment() { + // Do not load parent comment entity. return (bool) $this->get('pid')->target_id; } diff --git a/core/modules/comment/templates/comment.html.twig b/core/modules/comment/templates/comment.html.twig index 75604b9..c3bebda 100644 --- a/core/modules/comment/templates/comment.html.twig +++ b/core/modules/comment/templates/comment.html.twig @@ -45,7 +45,7 @@ * * These variables are provided to give context about the parent comment (if * any): - * - comment_parent: Full parent comment entity (if any). + * - parent_comment: Full parent comment entity (if any). * - parent_author: Equivalent to author for the parent comment. * - parent_created: Equivalent to created for the parent comment. * - parent_changed: Equivalent to changed for the parent comment. @@ -59,7 +59,7 @@ * * These two variables are provided for context: * - comment: Full comment object. - * - entity: Entity the comments are attached to. + * - commented_entity: Entity the comments are attached to. * * @see template_preprocess_comment() * @@ -93,9 +93,15 @@ Indicate the semantic relationship between parent and child comments for accessibility. The list is difficult to navigate in a screen reader without this information. + This information is presented to help screen readers follow lengthy + discussion threads. You can hide this from sighted users using the class + visually-hidden. #} - {% if parent %} -

{{ parent }}

+ {% if parent_comment %} +

+ {{ 'In reply to !parent_title by !parent_author'|t({ '!parent_title': + parent_title, '!parent_author': parent_author }) }} +

{% endif %} {{ permalink }}