Skip to content
Snippets Groups Projects
Commit 12ef050d authored by catch's avatar catch
Browse files

Issue #3092558 by recrit, vijaycs85, smustgrave, aloneblood, k9606, YesCT:...

Issue #3092558 by recrit, vijaycs85, smustgrave, aloneblood, k9606, YesCT: Revisions log on translated nodes should not show original language revisions, should show revisions of translated content

(cherry picked from commit 2feaa299)
parent 791cf59a
Branches
Tags
13 merge requests!8376Drupal views: adding more granularity to the ‘use ajax’ functionality,!8300Issue #3443586 View area displays even when parent view has no results.,!7567Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7565Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7509Change label "Block description" to "Block type",!7344Issue #3292350 by O'Briat, KlemenDEV, hswong3i, smustgrave, quietone: Update...,!6922Issue #3412959 by quietone, smustgrave, longwave: Fix 12 'un' words,!6848Issue #3417553 by longwave: Remove withConsecutive() in CacheCollectorTest,!6720Revert "Issue #3358581 by pfrenssen, _tarik_, a.dmitriiev, smustgrave:...,!6560Update ClaroPreRender.php, confirming classes provided are in array format,!6528Issue #3414261 by catch: Add authenticated user umami performance tests,!6501Issue #3263668 by omkar-pd, Wim Leers, hooroomoo: Re-enable inline form errors...,!6354Draft: Issue #3380392 by phma: Updating language weight from the overview reverts label if translated
Pipeline #82745 passed
Pipeline: drupal

#82747

    ......@@ -439,6 +439,104 @@ public function testNewTranslationSourceValues() {
    $this->assertSession()->pageTextContains('Test 1.3 EN');
    }
    /**
    * Tests article revision history shows revisions for the correct translation.
    */
    public function testTranslationRevisionsHistory() {
    // Create a published article in English.
    $edit = [
    'title[0][value]' => 'English node',
    'langcode[0][value]' => 'en',
    'moderation_state[0][state]' => 'published',
    'revision_log[0][value]' => 'Log Message - English - Published - Edit 1',
    ];
    $this->drupalGet('node/add/article');
    $this->submitForm($edit, 'Save');
    $this->assertSession()->pageTextContains('Article English node has been created.');
    $node = $this->drupalGetNodeByTitle('English node');
    // Add a French translation.
    $this->drupalGet('node/' . $node->id() . '/translations');
    $this->clickLink('Add');
    $edit = [
    'title[0][value]' => 'French node',
    'moderation_state[0][state]' => 'draft',
    'revision_log[0][value]' => 'Log Message - French - Draft - Edit 1',
    ];
    $this->submitForm($edit, 'Save (this translation)');
    // Here the error has occurred "The website encountered an unexpected error.
    // Try again later."
    // If the translation has got lost.
    $this->assertSession()->pageTextContains('Article French node has been updated.');
    $french_node = $this->loadTranslation($node, 'fr');
    $this->assertEquals('published', $node->moderation_state->value);
    $this->assertTrue($node->isPublished());
    $this->assertEquals('draft', $french_node->moderation_state->value);
    $this->assertFalse($french_node->isPublished());
    // Verify the revisions history for the English node.
    $this->drupalGet('node/' . $node->id() . '/revisions');
    $this->assertSession()->pageTextContains('Log Message - English - Published - Edit 1');
    $this->assertSession()->pageTextNotContains('Log Message - French');
    // Verify the revisions history for the French node.
    $this->drupalGet($french_node->language()->getId() . '/node/' . $node->id() . '/revisions');
    $this->assertSession()->pageTextContains('Log Message - French - Draft - Edit 1');
    $this->assertSession()->pageTextNotContains('Log Message - English');
    // Create a new draft for the English article.
    $edit = [
    'moderation_state[0][state]' => 'draft',
    'revision_log[0][value]' => 'Log Message - English - Draft - Edit 2',
    ];
    $this->drupalGet('node/' . $node->id() . '/edit');
    $this->submitForm($edit, 'Save');
    $this->assertSession()->pageTextContains('Article English node has been updated.');
    // Create a new draft for the French article.
    $edit = [
    'moderation_state[0][state]' => 'draft',
    'revision_log[0][value]' => 'Log Message - French - Draft - Edit 2',
    ];
    $this->drupalGet($french_node->language()->getId() . '/node/' . $node->id() . '/edit');
    $this->submitForm($edit, 'Save (this translation)');
    $this->assertSession()->pageTextContains('Article French node has been updated.');
    // Verify the revisions history for the English node.
    $this->drupalGet('node/' . $node->id() . '/revisions');
    $this->assertSession()->pageTextContains('Log Message - English - Published - Edit 1');
    $this->assertSession()->pageTextContains('Log Message - English - Draft - Edit 2');
    $this->assertSession()->pageTextNotContains('Log Message - French');
    // Verify the revisions history for the French node.
    $this->drupalGet($french_node->language()->getId() . '/node/' . $node->id() . '/revisions');
    $this->assertSession()->pageTextContains('Log Message - French - Draft - Edit 1');
    $this->assertSession()->pageTextContains('Log Message - French - Draft - Edit 2');
    $this->assertSession()->pageTextNotContains('Log Message - English');
    // Publish the French Node.
    $edit = [
    'moderation_state[0][state]' => 'published',
    'revision_log[0][value]' => 'Log Message - French - Published - Edit 3',
    ];
    $this->drupalGet($french_node->language()->getId() . '/node/' . $node->id() . '/edit');
    $this->submitForm($edit, 'Save (this translation)');
    $this->assertSession()->pageTextContains('Article French node has been updated.');
    // Verify the revisions history for the English node.
    $this->drupalGet('node/' . $node->id() . '/revisions');
    $this->assertSession()->pageTextContains('Log Message - English - Published - Edit 1');
    $this->assertSession()->pageTextContains('Log Message - English - Draft - Edit 2');
    $this->assertSession()->pageTextNotContains('Log Message - French');
    // Verify the revisions history for the French node.
    $this->drupalGet($french_node->language()->getId() . '/node/' . $node->id() . '/revisions');
    $this->assertSession()->pageTextContains('Log Message - French - Draft - Edit 1');
    $this->assertSession()->pageTextContains('Log Message - French - Draft - Edit 2');
    $this->assertSession()->pageTextContains('Log Message - French - Published - Edit 3');
    $this->assertSession()->pageTextNotContains('Log Message - English');
    }
    /**
    * Submits the node form at the current URL with the specified values.
    *
    ......
    ......@@ -142,6 +142,11 @@ public function revisionPageTitle(NodeInterface $node_revision) {
    * An array as expected by \Drupal\Core\Render\RendererInterface::render().
    */
    public function revisionOverview(NodeInterface $node) {
    // Always use the latest revision in the current content language to
    // determine if this node has translations. This supports showing the
    // correct translation revisions for translations that only have.
    // non-default revisions.
    $node = $this->entityRepository->getActive($node->getEntityTypeId(), $node->id());
    $langcode = $node->language()->getId();
    $language_name = $node->language()->getName();
    $languages = $node->getTranslationLanguages();
    ......@@ -152,7 +157,6 @@ public function revisionOverview(NodeInterface $node) {
    $header = [$this->t('Revision'), $this->t('Operations')];
    $rows = [];
    $default_revision = $node->getRevisionId();
    $current_revision_displayed = FALSE;
    foreach ($this->getRevisionIds($node, $node_storage) as $vid) {
    ......@@ -173,7 +177,7 @@ public function revisionOverview(NodeInterface $node) {
    // revision, if it was the default revision, as its values for the
    // current language will be the same of the current default revision in
    // this case.
    $is_current_revision = $vid == $default_revision || (!$current_revision_displayed && $revision->wasDefaultRevision());
    $is_current_revision = $revision->isDefaultRevision() || (!$current_revision_displayed && $revision->wasDefaultRevision());
    if (!$is_current_revision) {
    $link = Link::fromTextAndUrl($date, new Url('entity.node.revision', ['node' => $node->id(), 'node_revision' => $vid]))->toString();
    }
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment