Steps to reproduce:

  • Install Drupal 10.2.6
  • Enable a second language (any language)
  • configure a language prefix to determine current language
  • enable translation on a node bundle
  • enable revisioning on that node bundle
  • install the diff module and configure it
  • create content in that node bundle
  • translate that content
  • go to the revisions tab
  • Notice that Revision histories of translated nodes are not being taken into account. For instance, when I am viewing a node with the following url structure: /{langcode}/node/{vid}/revisions

SOLUTION:
Apply the patch

Revision histories of translated nodes are not being taken into account. For instance, when I am viewing a node with the following url structure:

/{langcode}/node/{vid}/revisions,

The current logic of $entity->moderation_state->value within the getModerationState() function fails to take into consideration the loaded language of the node in question. By default, the published states reflect the original node language revisions NOT the language specified by {langcode}.

Issue fork diff-3004705

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

toiletfinder.com created an issue. See original summary.

toiletfinder.com’s picture

Status: Active » Patch (to be ported)
toiletfinder.com’s picture

toiletfinder.com’s picture

awm’s picture

Status: Patch (to be ported) » Needs review
toiletfinder.com’s picture

Status: Needs review » Needs work

The last submitted patch, 6: getmoderationstate-func-not-considering-translations-3004705-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

toiletfinder.com’s picture

alan d.’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 8: getmoderationstate-func-not-considering-translations-3004705-3.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

simbaw’s picture

Status: Needs work » Needs review
StatusFileSize
new704 bytes

I have the same problem, and used the patch as below, this problem is solved.

Status: Needs review » Needs work

The last submitted patch, 11: ModerationState-error-of-translated-node-in-revision-overview-page-3004705-4.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

yesct’s picture

Assigned: toiletfinder.com » Unassigned
Issue tags: +Needs tests, +content translation, +content moderation

I also ran into this with drupal 8.7 and diff 8.x-1.0-rc2
patch 4 from #11 fixed the state showing in the node revision log for content with translation to other languages.

I suspect that the fails in the automated tests indicate the tests need updating, maybe they are testing something they dont mean to.
adding needs tests tag to indicate the next step is to update tests.

unassigning since it has been a while, and to indicate anyone can pick up the next steps.

maximpodorov’s picture

Version: 8.x-1.0-rc2 » 8.x-1.x-dev
Status: Needs work » Needs review

I confirm the patch #11 solves the problem. Let's test again.

maximpodorov’s picture

Status: Needs review » Reviewed & tested by the community

Well, the tests are green now. Let is be RTBC.

smulvih2’s picture

Patch #11 works for me.

dbielke1986’s picture

+1 Would be nice to see this patch in the upcoming release!

oleh.tarasiuk’s picture

kunalkursija’s picture

I faced this issue too, Where it seems like $entity->moderation_state->value seems to be ignoring the moderation state of the translated nodes. Thereby showing 1 moderation state for all the revisions visible on the revisions tab(of node translations).

Tried patch from #18 and it seems to be solving the problem.

alvarito75’s picture

Patch #18 also fixed the problem

Here is the project version that might help others:

  1. Drupal 10.2.2
  2. PHP 8.2.12
  3. Gin theme 3.0@RC
kevin w’s picture

Re-roll patch for v1.3.0

acbramley’s picture

Status: Reviewed & tested by the community » Needs work

Thank you for your contribution. This issue currently does not meet the Contribution guidelines which are required to get this change committed.

joseph.olstad’s picture

Issue summary: View changes
Status: Needs work » Needs review
joseph.olstad’s picture

Issue summary: View changes
joseph.olstad’s picture

Status: Needs review » Reviewed & tested by the community

Patch has been working well for over 6 years running and is still needed

joseph.olstad’s picture

Issue tags: -Needs tests

Existing test coverage should ensure that this doesn't cause regression.

It's been 6 years without test coverage. Would be good to fix this.

joseph.olstad’s picture

Issue summary: View changes

joseph.olstad’s picture

patch #11 is the one we've been using for years.

patch #18 and #21 failed phpstan, both of these patches are a bit tough on the eyes.

patch #11 passes tests, it's a one line fix.

6 years now and counting.

joseph.olstad’s picture

joseph.olstad’s picture

Same fix also applies to the 2.x branch

Here's the diff (patch compatible) from the MR.

acbramley’s picture

Version: 8.x-1.x-dev » 2.x-dev
Status: Reviewed & tested by the community » Needs work
Issue tags: -content translation, -content moderation +Needs tests

Existing test coverage should ensure that this doesn't cause regression.

We need test coverage for the bug fix.

It should go into 2.x first.

recrit’s picture

StatusFileSize
new763 bytes

posting a static patch for composer builds

joseph.olstad’s picture

joseph.olstad’s picture

We could borrow some test code from another contrib project that has language negotiation , bundle translation enabled.
Would have to dig a bit but I'm sure it's out there, most of the test code for this has already been written somewhere else.

recrit’s picture

@joseph.olstad using the automatically generated patch is dangerous since it is actively updated. A static patch is preferred to avoid any issues with new code pushed to the MR.

Consider the common scenario below.
- Day 1: Local development builds with the automatic patch. Composer lock is built.
- Day 2: MR is updated with new code, potentially incompatible with other patches to the module or custom code on the site.
- Day 3: Local development precedes, but composer.lock does not know the MR updated since the github URL has not changed.
- development continues ....
- Day 10: Staging deployment: This builds a fresh composer install, so it now pulls in the latest changes from the MR. The new changes cause the build to break.

joseph.olstad’s picture

The actual patch code it hasn't changed in several years.

with that said, all that is left is test coverage and that won't affect anyone using it.

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

gaurav_manerkar’s picture

Status: Needs work » Needs review
gaurav_manerkar’s picture

acbramley’s picture

Status: Needs review » Needs work

Still needs tests and linting is failing

goodmood’s picture

StatusFileSize
new1.44 KB

Rerolled patch for latest changes in 2.x branch so it can be applied to 2.0.0 version of the module

dbielke1986’s picture

Again +1 Would be nice to see this patch in the upcoming release!

:-)

acbramley’s picture

@goodmood changes must be posted to MRs, you can force push over MR156 since that is conflicting now.

@dbielke1986 it won't be in a release until we have a green MR with changes and associated tests.

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

mparker17’s picture

I found this didn't apply to 2.1.1, so I fixed the merge conflict and force-pushed over merge request !156 as requested by @acbramley in #45

hemuvyas97’s picture

Status: Needs work » Needs review
StatusFileSize
new1.47 KB

Rerolled patch for latest changes in 2.x branch so it can be applied to 2.1.1 version of the module

acbramley changed the visibility of the branch diff-3004705/3004705-the-getmoderationstate-function to hidden.

acbramley’s picture

Status: Needs review » Needs work

Still needs tests