diff -u b/core/modules/node/lib/Drupal/node/Controller/NodeController.php b/core/modules/node/lib/Drupal/node/Controller/NodeController.php --- b/core/modules/node/lib/Drupal/node/Controller/NodeController.php +++ b/core/modules/node/lib/Drupal/node/Controller/NodeController.php @@ -90,24 +90,30 @@ * An array suitable for drupal_render(). */ public function page(NodeInterface $node) { + $build = $this->buildPage($node); + foreach ($node->uriRelationships() as $rel) { $uri = $node->uri($rel); // Set the node path as the canonical URL to prevent duplicate content. - drupal_add_html_head_link(array( + $build['#attached']['drupal_add_html_head_link'][] = array( + array( 'rel' => $rel, 'href' => $this->urlGenerator()->generateFromPath($uri['path'], $uri['options']), - ), TRUE); + ) + , TRUE); if ($rel == 'canonical') { // Set the non-aliased canonical path as a default shortlink. - drupal_add_html_head_link(array( - 'rel' => 'shortlink', - 'href' => $this->urlGenerator()->generateFromPath($uri['path'], array_merge($uri['options'], array('alias' => TRUE))), - ), TRUE); + $build['#attached']['drupal_add_html_head_link'][] = array( + array( + 'rel' => 'shortlink', + 'href' => $this->urlGenerator()->generateFromPath($uri['path'], array_merge($uri['options'], array('alias' => TRUE))), + ) + , TRUE); } } - return $this->buildPage($node); + return $build; } /** only in patch2: unchanged: --- /dev/null +++ b/core/modules/node/lib/Drupal/node/Tests/NodeViewTest.php @@ -0,0 +1,44 @@ + 'Node view page', + 'description' => 'Tests the node/{node} page.', + 'group' => 'Node', + ); + } + + /** + * Tests the html head links. + */ + public function testHtmlHeadLinks() { + $node = $this->drupalCreateNode(); + + $uri = $node->uri(); + $this->drupalGet($uri['path']); + + $result = $this->xpath('//link[@rel = "version-history"]'); + $this->assertEqual($result[0]['href'], url("node/{$node->id()}/revisions")); + + $result = $this->xpath('//link[@rel = "edit-form"]'); + $this->assertEqual($result[0]['href'], url("node/{$node->id()}/edit")); + + $result = $this->xpath('//link[@rel = "canonical"]'); + $this->assertEqual($result[0]['href'], url("node/{$node->id()}")); + } + +}