Cannot save or publish originating node or translations. error "The content has either been modified by another user, or you have already submitted modifications ..."

Created on 14 June 2022, over 2 years ago
Updated 20 February 2024, 9 months ago

Drupal core and setup

- I found this issue in Drupal 9.2.19
- I have no chance to test weather this bug is in Drupal 9.3
- Related Modules: , Content Translation, Configuration Translation, Interface Translation.
- At least Four languages are added.

Problem/Motivation

  1. Logged in as None-admin user, such 'content editor'.
  2. English node and subsequent translations were created and moved through the CM (Content Moderation) process , draft, review, send back, review, publish, archive and un-archive. So the Source node (EN) and any created translation is now in Draft state after being unarchived, After creating more translations or when trying to re-Publish the English node (Draft) the error "The content has either been modified by another user, or you have already submitted modifications. As a result, your changes cannot be saved." is displayed and the node cannot be saved.
  3. English node was published and a translated node was published. Another translations is created as draft or needs review. Subsequent translations can not be created as draft or published.

Steps to reproduce

  1. As Content Editor, Add a Content type fill in required fields
  2. Save and Publish
  3. Create and Publish 2 translations
  4. Edit the English node and Save and Archive the page, leaving the translations published
  5. Edit the English node, Save and un-archive the page
  6. Edit one translation, Save and Archive it
  7. Edit the EN node and try to publish

Actual results

- error "The content has either been modified by another user, or you have already submitted modifications. As a result, your changes cannot be saved."

Proposed resolution

I made a patch file to change the Class EntityChangedConstraintValidator:

diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php
index 5a7b4b90c6..14e8f8b4a5 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php
@@ -31,8 +31,12 @@ public function validate($entity, Constraint $constraint) {
             // been edited and saved in the meanwhile. Therefore, compare the
             // changed timestamps of each entity translation individually.
             if ($saved_entity->getTranslation($langcode)->getChangedTime() > $entity->getTranslation($langcode)->getChangedTime()) {
-              $this->context->addViolation($constraint->message);
-              break;
+              $a = $saved_entity->getLoadedRevisionId();
+              $b = $entity->getLoadedRevisionId();
+              if ($a == $b) {
+                $this->context->addViolation($constraint->message);
+                break;
+              }
             }
           }
         }

Related Articles

- Drupal 8 Node Lock Issue, https://www.drupal.org/project/drupal/issues/2744851 β†’
- Core interfaces can go over max_input_vars, https://www.drupal.org/project/drupal/issues/1565704 β†’

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
EntityΒ  β†’

Last updated about 7 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States Gung Wang

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • In my case when I was trying to create a German translation of the node, based on the English version, I was receiving the error "The content has either been modified by another user, or you have already submitted modifications". By debugging the EntityChangedConstraintValidator.php->validade function, I was able to identify the error was with the French revision version,
    So, in order to solve this, I just open the French version, save a new revision of it, and then everything works fine

  • πŸ‡―πŸ‡΄Jordan omar alahmed Jordan

    I got similar to Rzanetti's scenario, I got the error when I was working on a draft (not the latest revision), and after I revert to the last revision, the error has gone, it seems there is something with the revisioning.

  • πŸ‡§πŸ‡·Brazil mabho Rio de Janeiro, RJ

    I came across the issue described in this thread because I was experiencing the same issue as @Gung Wang.

    I would say we can describe the problem in simpler terms:

    • Create a new translatable node as Draft
    • Edit it and move it to Published.
    • Now that it has already been published, let's edit it and move it to Draft again.
    • Create a new translation at this point and set it as Published.
    • Enter the edit form for the main language again and try to update its content. Save it and you get the rogue message on the cover of this topic: "The content has either been modified by another user, or you have already submitted modifications"
  • πŸ‡¬πŸ‡§United Kingdom Rory Downes

    Hi,
    In my case we had a published English translation (the main language) and a few others. We also had a not published Italian translation.

    When clicking add to German (no translation yet), editing the content and clicking on save this translation we got this message.

    This patch worked Drupal core 9.5.8. I tested as admin and as a content editor.

    Regards Rory

  • πŸ‡¬πŸ‡·Greece msti Heraklion

    I had the same problem, D 9.5.10
    The suggested fix worked.

  • πŸ‡«πŸ‡·France MacSim

    Same problem for me on a D9.5.11.
    The provided patch fixed it.
    Thanks

  • πŸ‡ΊπŸ‡ΈUnited States edmund.dunn Olympia, WA

    We used this successfully. We had this same error. Two revisions, one created by an automated migration job, the other by an editor, both within a few hours. This created a conflict of some sort. This solved the issue. Well done!

Production build 0.71.5 2024