diff --git a/core/modules/node/src/Controller/NodePreviewController.php b/core/modules/node/src/Controller/NodePreviewController.php index fab222e52691626298f883200f094ed45a8af35b..1a1c3cac50519064b5c4201f64d94999f16d51b1 100644 --- a/core/modules/node/src/Controller/NodePreviewController.php +++ b/core/modules/node/src/Controller/NodePreviewController.php @@ -22,26 +22,6 @@ public function view(EntityInterface $node_preview, $view_mode_id = 'full', $lan // Don't render cache previews. unset($build['#cache']); - foreach ($node_preview->uriRelationships() as $rel) { - // Set the node path as the canonical URL to prevent duplicate content. - $build['#attached']['html_head_link'][] = array( - array( - 'rel' => $rel, - 'href' => $node_preview->url($rel), - ) - , TRUE); - - if ($rel == 'canonical') { - // Set the non-aliased canonical path as a default shortlink. - $build['#attached']['html_head_link'][] = array( - array( - 'rel' => 'shortlink', - 'href' => $node_preview->url($rel, array('alias' => TRUE)), - ) - , TRUE); - } - } - return $build; } diff --git a/core/modules/node/src/Tests/PagePreviewTest.php b/core/modules/node/src/Tests/PagePreviewTest.php index 9777ccccb1b15ab29cfe3ca5fd46abc993efb299..2bfd2e71f8ec8d99dac0333c2a27f4adacd93099 100644 --- a/core/modules/node/src/Tests/PagePreviewTest.php +++ b/core/modules/node/src/Tests/PagePreviewTest.php @@ -296,6 +296,24 @@ function testPagePreviewWithRevisions() { // Check that the revision log field has the correct value. $this->assertFieldByName('revision_log[0][value]', $edit['revision_log[0][value]'], 'Revision log field displayed.'); + + // Save the node after coming back from the preview page so we can create a + // forward revision for it. + $this->drupalPostForm(NULL, [], t('Save')); + $node = $this->drupalGetNodeByTitle($edit[$title_key]); + + // Check that previewing a forward revision of a node works. This can not be + // accomplished through the UI so we have to use API calls. + // @todo Change this test to use the UI when we will be able to create + // forward revisions in core. + // @see https://www.drupal.org/node/2725533 + $node->setNewRevision(TRUE); + $node->isDefaultRevision(FALSE); + + /** @var \Drupal\Core\Controller\ControllerResolverInterface $controller_resolver */ + $controller_resolver = \Drupal::service('controller_resolver'); + $node_preview_controller = $controller_resolver->getControllerFromDefinition('\Drupal\node\Controller\NodePreviewController::view'); + $node_preview_controller($node, 'default'); } /**