 core/modules/comment/comment.api.php               |   28 +++++++++
 .../lib/Drupal/comment/CommentViewBuilder.php      |   60 +++++++++++++++++---
 2 files changed, 79 insertions(+), 9 deletions(-)

diff --git a/core/modules/comment/comment.api.php b/core/modules/comment/comment.api.php
index e43c577..a74e1e6 100644
--- a/core/modules/comment/comment.api.php
+++ b/core/modules/comment/comment.api.php
@@ -1,6 +1,7 @@
 <?php
 
 use Drupal\Core\Entity\EntityInterface;
+use Drupal\comment\Entity\CommentInterface;
 
 /**
  * @file
@@ -197,5 +198,32 @@ function hook_comment_delete(Drupal\comment\Comment $comment) {
 }
 
 /**
+ * Alter the links of a comment.
+ *
+ * @param array $links
+ *   A renderable array representing the comment links.
+ * @param \Drupal\comment\Entity\CommentInterface $entity
+ *   The comment being rendered.
+ * @param string $view_mode
+ *   The view mode in which the comment is being viewed.
+ * @param string $langcode
+ *   The language in which the comment is being viewed.
+ * @param \Drupal\Core\Entity\EntityInterface $commented_entity
+ *   The entity to which the comment is attached.
+ *
+ * @see \Drupal\comment\CommentViewBuilder::renderLinks()
+ * @see \Drupal\comment\CommentViewBuilder::buildLinks()
+ */
+function hook_comment_links_alter(array $links, CommentInterface $entity, $view_mode, $langcode, EntityInterface $commented_entity) {
+  $container = \Drupal::getContainer();
+  $links['comment-report'] = array(
+    'title' => t('Report'),
+    'href' => "comment/{$entity->id()}/report",
+    'html' => TRUE,
+    'query' => array('token' => $container->get('csrf_token')->get("comment/{$entity->id()}/report")),
+  );
+}
+
+/**
  * @} End of "addtogroup hooks".
  */
diff --git a/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php b/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php
index 2713d52..6c5c554 100644
--- a/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php
+++ b/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php
@@ -127,13 +127,17 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang
       $entity->content['#entity'] = $entity;
       $entity->content['#theme'] = 'comment__' . $entity->field_id->value . '__' . $commented_entity->bundle();
       $entity->content['links'] = array(
-        '#theme' => 'links__comment',
-        '#pre_render' => array('drupal_pre_render_links'),
-        '#attributes' => array('class' => array('links', 'inline')),
+        '#type' => 'render_cache_placeholder',
+        '#callback' => '\Drupal\comment\CommentViewBuilder::renderLinks',
+        '#context' => array(
+          'comment_entity_id' => $entity->id(),
+          'view_mode' => $view_mode,
+          'langcode' => $langcode,
+          'commented_entity_type' => $commented_entity->entityType(),
+          'commented_entity_id' => $commented_entity->id(),
+          'in_preview' => !empty($entity->in_preview),
+        ),
       );
-      if (empty($entity->in_preview)) {
-        $entity->content['links'][$this->entityType] = $this->buildLinks($entity, $commented_entity);
-      }
 
       if (!isset($entity->content['#attached'])) {
         $entity->content['#attached'] = array();
@@ -146,6 +150,42 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang
   }
 
   /**
+   * #post_render_cache callback; replaces the placeholder with comment links.
+   *
+   * Renders the links on a comment.
+   *
+   * @param array $context
+   *   An array with the following keys:
+   *   - comment_entity_id: a comment entity ID
+   *   - view_mode: the view mode in which the comment entity is being viewed
+   *   - langcode: in which language the comment entity is being viewed
+   *   - commented_entity_type: the entity type to which the comment is attached
+   *   - commented_entity_id: the entity ID to which the comment is attached
+   *   - in_preview: whether the comment is currently being previewed
+   *
+   * @return array
+   *   A renderable array representing the comment links.
+   */
+  public static function renderLinks(array $context) {
+    $entity = entity_load('comment', $context['comment_entity_id']);
+    $commented_entity = entity_load($context['commented_entity_type'], $context['commented_entity_id']);
+
+    $links = array(
+      '#theme' => 'links__comment',
+      '#pre_render' => array('drupal_pre_render_links'),
+      '#attributes' => array('class' => array('links', 'inline')),
+    );
+    if (!$context['in_preview']) {
+      $links['comment'] = self::buildLinks($entity, $commented_entity);
+    }
+
+    // Allow other modules to alter the comment links.
+    drupal_alter('comment_links', $links, $entity, $context['view_mode'], $context['langcode'], $commented_entity);
+
+    return $links;
+  }
+
+  /**
    * Build the default links (reply, edit, delete …) for a comment.
    *
    * @param \Drupal\comment\Entity\CommentInterface $entity
@@ -156,10 +196,12 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang
    * @return array
    *   An array that can be processed by drupal_pre_render_links().
    */
-  protected function buildLinks(CommentInterface $entity, EntityInterface $commented_entity) {
+  protected static function buildLinks(CommentInterface $entity, EntityInterface $commented_entity) {
     $links = array();
     $status = $commented_entity->get($entity->field_name->value)->status;
 
+    $container = \Drupal::getContainer();
+
     if ($status == COMMENT_OPEN) {
       if ($entity->access('delete')) {
         $links['comment-delete'] = array(
@@ -188,7 +230,7 @@ protected function buildLinks(CommentInterface $entity, EntityInterface $comment
           'title' => t('Approve'),
           'href' => "comment/{$entity->id()}/approve",
           'html' => TRUE,
-          'query' => array('token' => $this->csrfToken->get("comment/{$entity->id()}/approve")),
+          'query' => array('token' => $container->get('csrf_token')->get("comment/{$entity->id()}/approve")),
         );
       }
       if (empty($links)) {
@@ -203,7 +245,7 @@ protected function buildLinks(CommentInterface $entity, EntityInterface $comment
     }
 
     // Add translations link for translation-enabled comment bundles.
-    if ($this->moduleHandler->moduleExists('content_translation') && content_translation_translate_access($entity)) {
+    if ($container->get('module_handler')->moduleExists('content_translation') && content_translation_translate_access($entity)) {
       $links['comment-translations'] = array(
         'title' => t('Translate'),
         'href' => 'comment/' . $entity->id() . '/translations',
