Problem/Motivation
There might be easier ways to reproduce this but this is what our customer managed to do and I couldn't reproduce in a simpler way yet.
Given 3 languages, EN, DE and FR.
Create node in EN, published
Add translation in DE, published.
Edit EN, change language to FR, draft. (related but less severe bug: the user is forwarded to en/node/X/latest, which is an access denied)
The result is that both en/node/X/edit and fr/node/X/edit are throwing an exception, only de/node/X/edit still works.
The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">LogicException</em>: The default translation flag cannot be changed (en). in <em class="placeholder">Drupal\Core\Entity\ContentEntityBase->onChange()</em> (line <em class="placeholder">832</em> of <em class="placeholder">core/lib/Drupal/Core/Entity/ContentEntityBase.php</em>). <pre class="backtrace">Drupal\Core\Entity\Plugin\DataType\EntityAdapter->onChange('default_langcode') (Line: 77)
Drupal\Core\TypedData\Plugin\DataType\ItemList->setValue(Array, 1) (Line: 107)
Drupal\Core\Field\FieldItemList->setValue(Array, 1) (Line: 628)
Drupal\Core\Entity\ContentEntityBase->set('default_langcode', Array) (Line: 328)
Drupal\Core\Entity\ContentEntityStorageBase->createRevision(Object, ) (Line: 294)
Drupal\content_moderation\EntityTypeInfo->entityPrepareForm(Object, 'edit', Object) (Line: 156)
content_moderation_entity_prepare_form(Object, 'edit', Object)
call_user_func_array('content_moderation_entity_prepare_form', Array) (Line: 408)
Drupal\Core\Entity\EntityForm->prepareInvokeAll('entity_prepare_form', Object) (Line: 139)
Drupal\Core\Entity\EntityForm->init(Object) (Line: 291)
Drupal\Core\Entity\ContentEntityForm->init(Object) (Line: 107)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 519)
Drupal\Core\Form\FormBuilder->retrieveForm('node_primer_page_edit_form', Object) (Line: 276)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 697)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
</pre>
Proposed resolution
I'm not sure?
Disallow changing the default language in a draft? Or allow to edit content in this scenario?
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet