Skip to content
Snippets Groups Projects
Commit 2feaa299 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
parent be8a77d8
Branches
Tags
26 merge requests!8528Issue #3456871 by Tim Bozeman: Support NULL services,!3878Removed unused condition head title for views,!38582585169-10.1.x,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3668Resolve #3347842 "Deprecate the trusted",!3651Issue #3347736: Create new SDC component for Olivero (header-search),!3531Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!3355Issue #3209129: Scrolling problems when adding a block via layout builder,!3226Issue #2987537: Custom menu link entity type should not declare "bundle" entity key,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2334Issue #3228209: Add hasRole() method to AccountInterface,!2062Issue #3246454: Add weekly granularity to views date sort,!1105Issue #3025039: New non translatable field on translatable content throws error,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #82737 passed
Pipeline: drupal

#82739

    ......@@ -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();
    }
    ......
    • catch @catch

      mentioned in commit 12ef050d

      ·

      mentioned in commit 12ef050d

      Toggle commit list
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment