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 Moderation, Language, 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

Issue fork drupal-3285657

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

Gung Wang created an issue. See original summary.

gung wang’s picture

Issue summary: View changes
gung wang’s picture

Issue summary: View changes
gung wang’s picture

Title: Cannot save or publish originating node or translations. error "The content has either been modified by another user, or you have already submitted modifications. As a result, your changes cannot be saved." » Cannot save or publish originating node or translations. error "The content has either been modified by another user, or you have already submitted modifications ..."
gung wang’s picture

Issue summary: View changes
gung wang’s picture

Issue summary: View changes
cilefen’s picture

Version: 9.2.x-dev » 9.4.x-dev
Status: Active » Needs work
Issue tags: -EntityChangedConstraintValidator

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

rzanetti’s picture

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

omar alahmed’s picture

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.

mabho’s picture

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"

Now, to the heart of the problem: when a translation is published after the latest revision, author/user cannot save a new revision in the original language any longer.

rory downes’s picture

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

msti’s picture

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

macsim’s picture

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

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

edmund.dunn’s picture

We used this successfully. We had this same error on 10.2.2. 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!

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

bserem’s picture

Status: Needs work » Needs review

I made an MR against 11.x
It's nothing new, it's the same patch from 4 years ago, superb work from @gungwang!
@cilefen you added no comments as to why this needs work, so I'm bumping it to needs review.

The patch works and does solve the issue. In our case it was also a migration that created revisions. Languages are enabled but the problem exists even without translations in place.

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

joshuami’s picture

In my testing of the patch, it worked for most use cases but failed on some edge cases related to creating a new translated revision in a new moderation state (for example, moving content from published to archived and back to draft). It would hide the error, but the validation still prevented the revision from being saved.

This updated approach checks to see whether a new revision will be created by the moderation state change in addition to just comparing revision IDs. Helpful when translation is being turned on for moderated content that was not previously translatable or in cases where published status was not a translated field.

I've also added some test coverage.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

Left some comments around the test.