Issue #2684213 by amateescu, larowlan, josephdpurcell, dawehner: Preview on forward node revisions throws an error
parent
cf6909c8ff
commit
c5bfca6470
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue