Problem/Motivation
This issue manifests itself in a couple of ways:
- When switching from a specific language to "Not specified", since you cannot add multiple translations when this is selected, content moderation errors out attempting to add this as a new language.
- When switching between languages, the content moderation state entity tables will continue to fill up with new translations, where the host entity will retain just one.
Using the following steps, a fatal can be triggered from the UI:
- Add 2 languages
- Install workflow, content moderation and content translation
- Enable content translation and content moderation on any node bundle
- Create a node in one of the installed languages as a "Draft".
- Edit the node and change the language to "Not specified"
This results in:
Invalid translation language (und) specified. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 805 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Drupal\content_moderation\EntityOperations->updateOrCreateFromEntity(Object) (Line: 135) Drupal\content_moderation\EntityOperations->entityUpdate(Object) (Line: 91) content_moderation_entity_update(Object) call_user_func_array('content_moderation_entity_update', Array) (Line: 402)
Proposed resolution
When the default language of an entity is being changed, change the default language of the content_moderation_state entity.
Remaining tasks
Review + commit.