Problem/Motivation

When viewing the revision log for a translated node, the moderation state reflects the current state of the default translated (English) node. I would like to see the actual moderation state of the revision regardless of translation.

Steps to reproduce

  • Enable Content Moderation
  • Enable Content Translation
  • Within Content Moderation config, add your desired states.
  • Within the Content Translation config, add a new language to support and apply to any given content type.
  • For the content type that is translatable, and both default and ie. Spanish translations and Publish them.
  • Make an update to the Spanish translation and save with a different moderation state such as Draft.
  • View the revision log for the Spanish translation and the status will say Publish, not Draft. (Here lies the issue.)

Proposed resolution

Update the method which displays the moderation state and alter so that it references the moderation state for the actual revision/translation.
The DiffEntityComparison::getModerationState() is where this can be updated.

Issue fork diff-3269933

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dcrowder created an issue. See original summary.

dcrowder’s picture

StatusFileSize
new870 bytes

Renamed the patch to include module and ticket number. There isn't any difference with the patch itself.

tedfordgif’s picture

Version: 8.x-1.0 » 8.x-1.x-dev
StatusFileSize
new787 bytes

Updated with patch that applies without error.

dan2k3k4’s picture

I found a similar issue but went about fixing it differently by directly ensuring we load the right language for the revision.

colorfield’s picture

Tested #4 manually and confirming that it solves the issue

m_z’s picture

+1 Tested #4 successfully --> I would suggest a status change to RTBC

dbielke1986’s picture

+1 Tested #4 successfully

liquidcms’s picture

Status: Needs review » Reviewed & tested by the community

works for me.

agentrickard’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new19.11 KB
new47.32 KB
new7.25 KB

I don't believe the current patch works correctly when there is *not* an affected translation. In that event, the UI skips revisions that have no translation.

See similar issue in #2882334: Revisions are not visible for some nodes

I think what we want to do is ensure the proper *translated* revision is loaded, not that it exists or not.

This patch also adds the VID to the output.

BEFORE REVISED PATCH:

Before

AFTER PATCH:

After

Status: Needs review » Needs work

The last submitted patch, 9: diff-3269933-get-revision-with-langcode-9.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

agentrickard’s picture

Status: Needs work » Needs review
StatusFileSize
new4.45 KB

The failing tests here are because the current tests assume that only current language revisions are loaded. However, in my quick tests, that only seems to be a condition if translations actually exist.

What I don't know -- and why I didn't update the tests -- is this:

* If a site is set for multilngual but no translations of a node exist -- what should appear on the translated node revisions tab?

To be clear, I am dealing with a site that defaults to EN but allows ES translations. Without the patch in #9, some revisions are missing for nodes that are not yet translated.

I think the attached approach -- checking against the $current_langcode -- is correct, but can't be sure.

Status: Needs review » Needs work

The last submitted patch, 11: diff-3269933-get-revision-with-langcode-11.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

mrshowerman’s picture

This issue is in fact closely related to #2882334: Revisions are not visible for some nodes, as stated in #9. I created a MR for that issue and added the change from #4 to it, so both issues are fixed with one change.

recrit’s picture

This issue appears to be related to #3418442: Revisions should be filtered by language in the database query. See patch #5 that correctly checks whether the entity type is translatable and it updates the automated tests.

recrit’s picture

twod’s picture

Status: Needs work » Needs review
StatusFileSize
new10.26 KB
new4.54 KB

#11 I think listing all revisions, instead of just the affected ones, is making it hard to tell how many changes there actually were to the translation being viewed. That could be a lot of revisions even with just two languages. Our use case is similar, with mostly Swedish nodes with some English translations here and there, but there can still be a large number of revisions.
I'm also not quite sure this actually fixes the issue, see below.

+++ b/src/Form/RevisionOverviewForm.php
@@ -209,15 +210,23 @@ class RevisionOverviewForm extends FormBase {
+        // If dealing with a translation, load that version.
+        if (($revision->hasTranslation($langcode) && $revision->isRevisionTranslationAffected()) ||
+          $langcode === $current_langcode || !$revision->hasTranslation($current_langcode)
+        ) {

This says it'll load a translation if one exists, but never actually does.

This condition also looks like it will always be true because $langcode is the entity's current language, which is by default the same as $current_language.

I took a slightly different approach and added the query filtering @recrit mentioned, which also meant a few conditions could be removed, and then added a check to figure out which older revision the current revision was based on, if it does not affect the viewed translation.
(I kept the hasTranslation check to be safe, since switching to one that does not exist throws an exception.)

The interdiff was generated without white-space changes to make the indentation changes easier on the eyes.
(Tests not updated yet.)

Status: Needs review » Needs work

The last submitted patch, 17: diff-3269933-17.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

twod’s picture

StatusFileSize
new10.26 KB
new1.99 KB

I tried to be clever in the check for what would correspond to the default revision content and it already bit me, so modifying it and the message to better reflect reality.

twod’s picture

StatusFileSize
new10.29 KB
new4.8 KB

Tweaked the wording a bit, also made the interdiff against 11 to be more clear about all the changes since, again without white-space changes and test fixes.

silvi.addweb made their first commit to this issue’s fork.

suhaib_hija’s picture

StatusFileSize
new9.42 KB

Reroll patch #20 for diff 8.x-1.7

acbramley’s picture

Version: 8.x-1.x-dev » 2.x-dev
Issue tags: -diff, -Moderation states revision history, -moderation state, -revisions +Needs tests

This issue needs an MR (not the 8.x-1.x or 2.x branch as a source please) against the 2.x branch with tests.

codebymikey made their first commit to this issue’s fork.

codebymikey’s picture

StatusFileSize
new11.15 KB

Rerolled the #24 patch as a issue fork branch for 8.x-1.x, with some minor improvements (show the revision ID as a translatable text, as well as an utility revision-was-default class to dictate if the highlighted revision was a previous revision, rather than the default current revision.)

suhaib_hija’s picture

Rerolled patch #20 for 2.0.0-beta4

suhaib_hija’s picture

StatusFileSize
new10.69 KB

Rerolled patch #20 for 2.0.0-beta4

suhaib_hija’s picture

Status: Needs work » Needs review
acbramley’s picture

Status: Needs review » Needs work

Contributions must be made via MRs, not patches. And we'll need tests as per the issue tags.

divyansh.gupta’s picture

Assigned: Unassigned » divyansh.gupta

Working on tests.

divyansh.gupta changed the visibility of the branch 3269933-8.1.x-inconsistent-moderation-state to hidden.

divyansh.gupta changed the visibility of the branch 3269933-inconsistent-moderation-state to hidden.

divyansh.gupta changed the visibility of the branch 2.x to hidden.

divyansh.gupta’s picture

Assigned: divyansh.gupta » Unassigned
Status: Needs work » Needs review

Converted patch into MR, also added test to verify this,
Please review!!

acbramley’s picture

Status: Needs review » Needs work

Tests are failing and there seems to be a lot of unrelated changes in there.

This also seems likely to have overlap or duplicate with these issues that are all postponed on fixing a related issue in core, once the core issue is fixed we will apply the same logic to Diff.

#3227907: Current revision listed only for one translation
#3418442: Revisions should be filtered by language in the database query
#2882334: Revisions are not visible for some nodes

Core issue #2722307: Move translation based conditions into database query on revisions overview page

charlliequadros made their first commit to this issue’s fork.

charlliequadros changed the visibility of the branch 3269933- to hidden.