diff --git a/core/lib/Drupal/Core/Revision/RevisionControllerTrait.php b/core/lib/Drupal/Core/Revision/RevisionControllerTrait.php index ac8b012..6fd5242 100644 --- a/core/lib/Drupal/Core/Revision/RevisionControllerTrait.php +++ b/core/lib/Drupal/Core/Revision/RevisionControllerTrait.php @@ -170,39 +170,47 @@ public function revisionOverview(ContentEntityInterface $entity) { $vids = $entity_storage->revisionIds($entity); foreach (array_reverse($vids) as $vid) { - if ($revision = $entity_storage->loadRevision($vid)) { - $row = array(); - - if ($vid == $entity->getRevisionId()) { - $row[] = $this->getRevisionDetails($revision, TRUE); - $row[] = array('data' => SafeMarkup::placeholder($this->t('current revision')), 'class' => array('revision-current')); + $revision = $entity_storage->loadRevision($vid); + + $row = []; + + if ($vid == $entity->getRevisionId()) { + $row[] = $this->getRevisionDescription($revision, TRUE); + $row[0]['class'] = ['revision-current']; + $row[] = [ + 'data' => [ + '#prefix' => '', + '#markup' => $this->t('current revision'), + '#suffix' => '', + ], + 'class' => ['revision-current'], + ]; + } + else { + $row[] = $this->getRevisionDescription($revision, FALSE); + $links = []; + if ($revert_permission) { + $links['revert'] = $this->buildRevertRevisionLink($entity, $vid); } - else { - $row[] = $this->getRevisionDetails($revision, FALSE); - $links = []; - if ($revert_permission) { - $links['revert'] = $this->buildRevertRevisionLink($entity, $vid); - } - if ($delete_permission) { - $links['delete'] = $this->buildDeleteRevisionLink($entity, $vid); - } - $row[] = array( - 'data' => array( - '#type' => 'operations', - '#links' => $links, - ), - ); + if ($delete_permission) { + $links['delete'] = $this->buildDeleteRevisionLink($entity, $vid); } - $rows[] = $row; + $row[] = [ + 'data' => [ + '#type' => 'operations', + '#links' => $links, + ], + ]; } + + $rows[] = $row; } $build[$this->getRevisionEntityTypeId() . '_revisions_table'] = array( '#theme' => 'table', '#rows' => $rows, '#header' => $header, - ); return $build; diff --git a/core/modules/node/src/Controller/NodeController.php b/core/modules/node/src/Controller/NodeController.php index 12d824f..0198b88 100644 --- a/core/modules/node/src/Controller/NodeController.php +++ b/core/modules/node/src/Controller/NodeController.php @@ -229,26 +229,34 @@ protected function getRevisionDescription(EntityInterface $revision, $is_current '#account' => $revision_author, ); if ($is_current) { - return [ - 'data' => $this->t('!date by !username', [ - '!date' => $revision->link($this->dateFormatter->format($revision->revision_timestamp->value, 'short')), - '!username' => $this->renderer->render($username) - ]) - . (($revision->revision_log->value != '') ? '

' . Xss::filter($revision->revision_log->value) . '

' : ''), - 'class' => ['revision-current'], - ]; + $date = $revision->link($this->dateFormatter->format($revision->revision_timestamp->value, 'short')); } else { - return $this->t('!date by !username', [ - '!date' => $this->l($this->dateFormatter->format($revision->revision_timestamp->value, 'short'), new Url('node.revision_show', [ - 'node' => $revision->id(), - 'node_revision' => $revision->getRevisionId(), - ])), - '!username' => $this->renderer->render($username), - ]) - . (($revision->revision_log->value != '') ? '

' . Xss::filter($revision->revision_log->value) . '

' : ''); - + $date = $this->l($this->dateFormatter->format($revision->revision_timestamp->value, 'short'), new Url('entity.node.revision', [ + 'node' => $revision->id(), + 'node_revision' => $revision->getRevisionId(), + ])); } + + $description = [ + 'data' => [ + '#type' => 'inline_template', + '#template' => '{% trans %}{{ date }} by {{ username }}{% endtrans %}{% if message %}

{{ message }}

{% endif %}', + '#context' => [ + 'date' => $date, + 'username' => $this->renderer->renderPlain($username), + 'message' => [ + '#markup' => $revision->revision_log->value, + '#allowed_tags' => Xss::getHtmlTagList() + ], + ], + ], + ]; + + // @todo Simplify once https://www.drupal.org/node/2334319 lands. + $this->renderer->addCacheableDependency($description['data'], $username); + + return $description; } /**