The module displays the concurrent edit warning messages regardless if the revision translation is affected. For example, a page is created with English as the base language and then translated to French. If the English page is edited while someone also edits the French version, a concurrent edit warning will be displayed even though the edit(s) on the French revision do not affect the English revision.

The fix I am proposing uses isRevisionTranslationAffected() to only show the warning message when the page revisions are for the same language.

1. Clean drupal 8.6.x
2. Modules: Content Moderation, Workflows, Language, Content Translation
3. Install second language (example: French)
4. Allow content to be translated (all fields for basic page content type) /admin/config/regional/content-language
5. Create basic page with English as base language.
6. Translate same page to French.
7. Edit both at the same time (separate browser tabs/windows).
8. Modify English page and save as Draft.
9. French page will display concurrent edit warning message.

I would also propose the module uses isLiveRevision() rather than isPublished() to determine if the 'published' warning message is displayed. Currently the published warning message is always displayed after a page is published regardless of the moderation state. By using isLiveRevision(), a page that has been published but is currently being edited (draft or any other moderation state), will display the draft warning message.

1. Clean drupal 8.6.x
2. Modules: Content Moderation, Workflows
3. Create and publish basic page.
7. Edit page in two different browser tabs or windows.
8. Modify and save as Draft in one tab.
9. The other tab will display 'Published' concurrent edit warning message even though the edited page has a moderation state of 'Draft'.

CommentFileSizeAuthor
#2 3041132-2.patch2.13 KBdgilbert

Comments

dgilbert created an issue. See original summary.

dgilbert’s picture

StatusFileSize
new2.13 KB
mogtofu33’s picture

Thanks a lot for this patch.
I only have 2 remarks:

$lang_code = \Drupal::languageManager()->getCurrentLanguage()->getId();

Isn't it better to get the current langcode of the node ?
Because this return the current interface language that can be different from the current node.
Probably need to test this case (interface language != current node).

if ($latest_revision->getTranslation($lang_code)->isRevisionTranslationAffected() != '1') {

This method isRevisionTranslationAffected return a boolean, so we should check more for that type instead of '1' ?

Regards.

mogtofu33’s picture

Assigned: Unassigned » mogtofu33
Status: Active » Needs work

  • mogtofu33 committed 1572a3e on 8.x-1.x
    Issue #3041132 by dgilbert: Module does not handle translated revisions...
mogtofu33’s picture

Status: Needs work » Fixed

Added some tests for this and patch ported.
Thanks.

dgilbert’s picture

Thanks for fixing this!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.