summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2016-06-24 14:05:38 (GMT)
committerAlex Pott2016-06-24 14:05:38 (GMT)
commitc5bfca6470474bc6e24b0dec9bf8fa673cee3fb0 (patch)
treec1cd93f0b83ab7076555fe148215364d352fb538
parentcf6909c8ff72e6f46177bd92b414bb050c83a8fb (diff)
Issue #2684213 by amateescu, larowlan, josephdpurcell, dawehner: Preview on forward node revisions throws an error
-rw-r--r--core/modules/node/src/Controller/NodePreviewController.php20
-rw-r--r--core/modules/node/src/Tests/PagePreviewTest.php18
2 files changed, 18 insertions, 20 deletions
diff --git a/core/modules/node/src/Controller/NodePreviewController.php b/core/modules/node/src/Controller/NodePreviewController.php
index fab222e..1a1c3ca 100644
--- a/core/modules/node/src/Controller/NodePreviewController.php
+++ b/core/modules/node/src/Controller/NodePreviewController.php
@@ -22,26 +22,6 @@ class NodePreviewController extends EntityViewController {
// 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 9777ccc..2bfd2e7 100644
--- a/core/modules/node/src/Tests/PagePreviewTest.php
+++ b/core/modules/node/src/Tests/PagePreviewTest.php
@@ -296,6 +296,24 @@ class PagePreviewTest extends NodeTestBase {
// 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');
}
/**