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 2feaa29915
)
merge-requests/6354/head
parent
791cf59ae4
commit
12ef050dac
|
@ -439,6 +439,104 @@ class ModerationLocaleTest extends ModerationStateTestBase {
|
|||
$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 @@ class NodeController extends ControllerBase implements ContainerInjectionInterfa
|
|||
* 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 @@ class NodeController extends ControllerBase implements ContainerInjectionInterfa
|
|||
$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 @@ class NodeController extends ControllerBase implements ContainerInjectionInterfa
|
|||
// 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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue