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
- Logged in as None-admin user, such 'content editor'.
- 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.
- 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
- As Content Editor, Add a Content type fill in required fields
- Save and Publish
- Create and Publish 2 translations
- Edit the English node and Save and Archive the page, leaving the translations published
- Edit the English node, Save and un-archive the page
- Edit one translation, Save and Archive it
- 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