Commit 4e67ac59 authored by catch's avatar catch
Browse files

Issue #2866619 by acbramley, kksandr, shabana.navas, hkirsman: Don't use link...

Issue #2866619 by acbramley, kksandr, shabana.navas, hkirsman: Don't use link in message after node save if user doesn't have permissions

(cherry picked from commit 4892d23b)
parent a1b3926d
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -281,7 +281,7 @@ public function save(array $form, FormStateInterface $form_state) {
    $node->save();
    $node_link = $node->toLink($this->t('View'))->toString();
    $context = ['@type' => $node->getType(), '%title' => $node->label(), 'link' => $node_link];
    $t_args = ['@type' => node_get_type_label($node), '%title' => $node->toLink()->toString()];
    $t_args = ['@type' => node_get_type_label($node), '%title' => $node->access('view') ? $node->toLink()->toString() : $node->label()];

    if ($insert) {
      $this->logger('content')->info('@type: added %title.', $context);
+3 −2
Original line number Diff line number Diff line
@@ -183,8 +183,9 @@ public function testUnpublishedNodeCreation(): void {
    // Confirm that the node was created.
    $this->assertSession()->pageTextContains('Basic page ' . $edit['title[0][value]'] . ' has been created.');

    // Verify that the creation message contains a link to a node.
    $this->assertSession()->elementExists('xpath', '//div[@data-drupal-messages]//a[contains(@href, "node/")]');
    // Verify that the creation message doesn't contain a link to a node since
    // the user cannot view unpublished nodes.
    $this->assertSession()->elementNotExists('xpath', '//div[@data-drupal-messages]//a[contains(@href, "node/")]');
  }

  /**