Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 298347

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

$
0
0

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


Viewing all articles
Browse latest Browse all 298347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>