diff --git a/core/modules/comment/comment.tokens.inc b/core/modules/comment/comment.tokens.inc index b21f02b..4be0943 100644 --- a/core/modules/comment/comment.tokens.inc +++ b/core/modules/comment/comment.tokens.inc @@ -122,7 +122,8 @@ function comment_tokens($type, $tokens, array $data = array(), array $options = if ($type == 'comment' && !empty($data['comment'])) { /** @var \Drupal\comment\CommentInterface $comment */ - $comment = $data['comment']; + $comment = \Drupal::entityManager() + ->getTranslationFromContext($data['comment'], $langcode, array('operation' => 'comment_tokens')); foreach ($tokens as $name => $original) { switch ($name) { @@ -150,8 +151,8 @@ function comment_tokens($type, $tokens, array $data = array(), array $options = break; case 'body': - $translation = \Drupal::entityManager()->getTranslationFromContext($comment, $langcode, array('operation' => 'comment_tokens')); - if ($translation->hasField('comment_body') && ($items = $translation->get('comment_body')) && !$items->isEmpty()) { + // @todo Rename token to comment_body to prevent collisions with contrib. + if ($comment->hasField('comment_body') && ($items = $comment->get('comment_body')) && !$items->isEmpty()) { $replacements[$original] = $sanitize ? $items[0]->processed : $items[0]->value; } break;