Problem/Motivation
Currently the latest revision is loaded for the content moderation view. This is not always the revision that is loaded in entity forms during content editing, which is highly confusing. The entity converter which is responsible for deciding which revision should form the basis of the next edit doesn't actually load only the latest revision, but the latest translation affected revision:
...
// Retrieve the latest revision ID taking translations into account.
$langcode = $this->languageManager()
->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)
->getId();
$entity = $this->getLatestTranslationAffectedRevision($entity, $langcode);
...
Unless the views filter matches these semantics exactly, the views results are highly confusing and do not represent the revision which will actually be used as the basis for the next content edit. As far as users are concerned, when adding translations, drafts of the original language simply disappear (filtered out by the combination of the "latest" and "not published" filters in the views configuration).
Proposed resolution
Introduce a "LatestRevisionTranslationAffected" filter, ensure the content moderation view uses this.
Remaining tasks
Add a filter plugin for "latest translation affected revision".- Run an update on the content moderation view to use this plugin (with a test).
- Write a functional test for content moderation to verify all the components working together.
User interface changes
Fixes the content moderation view when used with multilingual sites.
API changes
An additional views filter.
Data model changes
Original report
I have created a new translatable content type and associated a workflow with 3 states to it. I created a new instance of this type and also created it's translation. Also a view has been created where the filter criteria was set to the Final (published, default revision) moderation state. As I set the moderation state of the original item to this Final value, the translated one seemed to remain in it's previous state (Draft), but the view lists both of the records like both were in the Final state.
Comment | File | Size | Author |
---|---|---|---|
#24 | 2983958-24.patch | 47 KB | Sam152 |
#24 | 2983958-integration-test-only-24.patch | 2.13 KB | Sam152 |
#24 | interdiff.txt | 427 bytes | Sam152 |
#22 | 2983958-22.patch | 47.02 KB | Sam152 |
#22 | interdiff.txt | 30.27 KB | Sam152 |
Comments
Comment #2
zolt_toth CreditAttribution: zolt_toth commentedComment #3
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedWould it be possible to get an export of the configuration of the view in question? It would also be helpful to see some of the relevant output from the content_moderation_state entity tables:
select * from content_moderation_state_field_revision;
Comment #4
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #5
olivier.br CreditAttribution: olivier.br commentedHi,
Maybe i can provide some details.
I have the same problem with this setup :
- Drupal core 8.6.1
- 2 languages enabled
- default workflow enabled for all content types.
The duplicate rows issue is solved by: https://www.drupal.org/project/drupal/issues/2977276
Remains this problem: the filter "Content revision: Is Latest Revision" filters the latest revision regardless the language.
ie :
- i have an original node in draft state, and i create a translated version in draft state -> the moderated content view only shows the translated version.
- I have an original node in draft state and a translated version in draft state, i publish the original node -> the moderated content view will display nothing because the latest revision for all multilingual versions is the published one.
I could reproduce this behavior on https://simplytest.me/ without any contrib module enable.
The filter "Content revision: Is Latest Revision" should filter the latest revision for each translated version.
Comment #6
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedThanks for the additional information, that's really helpful. I'm going to try reproduce this.
Comment #7
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedI can confirm using the steps from #5, when creating a pending revision of a translation, the latest revision of the default language seems to revert to "published". State of the CMS entity table:
And the content view:
So this this is actually working exactly as intended, the latest 'en' revision in this case was "published". So I think we actually need a filter which replicates the logic that is in our entity converter:
We need a filter that loads the latest translation affected revision, not the latest revision unconditionally.
Comment #8
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedFixing issue summary.
Comment #9
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #10
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedSome better wording of the root cause in the IS.
Comment #11
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #12
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedHere is a patch of the existing latest revision filter which works when combined with the other one. It'll need test coverage and to be moved into its own filter.
Comment #13
olivier.br CreditAttribution: olivier.br commentedpatch in #12 is solving the issue for me.
Thank you !
Comment #14
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedHere is the fix as a new filter with tests. Will still need an update hook and tests to replace the 'latest_revision' filter plugin with the 'latest_translation_affected_revision' plugin on the content moderation view.
Comment #15
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #17
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedAre you sure this needs to be a new filter? I think letting the use choose between a 'latest_revision' and a 'latest_translation_affected_revision' can get very confusing, so maybe it's easier to use the patch from #12 with an extra check on the entity type being translatable or not. And/or maybe make it configurable as well, with the behavior of checking the latest affected revision enabled by default, since that's most likely what the user would expect.
Comment #18
jibranThis makes sense to me.
This is not a test plugin this is an actual plugin so we should remove the suffix.
Comment #19
matsbla CreditAttribution: matsbla at Globalbility commentedI tested path #14 and it works great! To get such a filter could also maybe be helpful for #2999938: Replace content translation table with a view
Comment #20
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedThanks for the review!
I don't think it makes sense to change the behavior of the filter, given it's actually working correctly. I'm also not really a fan of making it configurable given it already feels quite complex. I'd rather they be split out so they can be documented, tested and iterated on in isolation. I think this is especially valid given the joins themselves are a candidate to be normalized into base tables in the future, having these as two seperate things may allow those to be unpicked easier down the line.
Comment #21
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedOkay, then let's go ahead with two filters :)
Comment #22
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedI think this is ready for a complete review. It includes:
Comment #24
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedFixing test name.
Comment #26
greggmarshallPatch #24 works in my case (documented in #3007456: Content Moderation State Field Revision with 2 Languages Set to Published). Thanks for a solution.
Comment #27
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedReviewed the patch again and it looks great. Nice to have some manual testing as well, thanks @greggmarshall :)
Comment #28
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedThanks for the manual testing and following up with another review.
Comment #30
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #31
pavlosdan CreditAttribution: pavlosdan as a volunteer commentedAnother +1 for this patch. We just came across the same issue as described by @greggmarshall in #3007456: Content Moderation State Field Revision with 2 Languages Set to Published which led us here. The new filter works as advertised :)
Comment #33
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedFail was in HEAD, back to RTBC.
Comment #34
Upchuk CreditAttribution: Upchuk as a volunteer commentedReferencing #3015312: The ModeratedNodeListBuilder does not show the correct revisions as it is responsible for achieving what the View is doing but via the list builder. They should go hand in hand.
Comment #35
catchThis looks like potentially a real test failure:
https://www.drupal.org/pift-ci-job/1115550
Comment #36
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedHey @catch, thanks for reviewing. The failure in that test run was introduced in HEAD and then reverted, so I don't think we've got an intermittent fail in this issue.
Comment #37
catchCommitted bd72409 and pushed to 8.7.x. Thanks!