Skip to content
Snippets Groups Projects

Fixed Inconsistency moderation state for translated content.

Closed Silvi Sanghavi requested to merge issue/diff-3269933:8.x-1.x into 8.x-1.x
1 file
+ 20
5
Compare changes
  • Side-by-side
  • Inline
@@ -141,6 +141,7 @@ class RevisionOverviewForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $node = NULL) {
$current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
$account = $this->currentUser;
/** @var \Drupal\node\NodeInterface $node */
$langcode = $node->language()->getId();
@@ -217,15 +218,22 @@ class RevisionOverviewForm extends FormBase {
}
/** @var \Drupal\Core\Entity\ContentEntityInterface $revision */
if ($revision = $node_storage->loadRevision($vid)) {
if ($revision->hasTranslation($langcode) && $revision->getTranslation($langcode)->isRevisionTranslationAffected()) {
// If dealing with a translation, load that version.
if (($revision->hasTranslation($langcode) && $revision->isRevisionTranslationAffected()) ||
$langcode === $current_langcode || !$revision->hasTranslation($current_langcode)
) {
$username = [
'#theme' => 'username',
'#account' => $revision->getRevisionUser(),
];
$revision_date = $this->date->format($revision->getRevisionCreationTime(), 'short');
// Data and vid string.
$revision_date = $this->date->format($revision->getRevisionCreationTime(), 'short') . " ($vid)";
// Use revision link to link to revisions that are not active.
if ($vid != $node->getRevisionId()) {
$link = Link::fromTextAndUrl($revision_date, new Url('entity.node.revision', ['node' => $node->id(), 'node_revision' => $vid]));
$link = Link::fromTextAndUrl($revision_date, new Url('entity.node.revision', [
'node' => $node->id(),
'node_revision' => $vid
]));
}
else {
$link = $node->toLink($revision_date);
@@ -266,8 +274,15 @@ class RevisionOverviewForm extends FormBase {
$links['revert'] = [
'title' => $vid < $node->getRevisionId() ? $this->t('Revert') : $this->t('Set as current revision'),
'url' => $has_translations ?
Url::fromRoute('node.revision_revert_translation_confirm', ['node' => $node->id(), 'node_revision' => $vid, 'langcode' => $langcode]) :
Url::fromRoute('node.revision_revert_confirm', ['node' => $node->id(), 'node_revision' => $vid]),
Url::fromRoute('node.revision_revert_translation_confirm', [
'node' => $node->id(),
'node_revision' => $vid,
'langcode' => $langcode
]) :
Url::fromRoute('node.revision_revert_confirm', [
'node' => $node->id(),
'node_revision' => $vid
]),
];
}
if ($delete_permission) {
Loading