Changing language of the default translation in a draft breaks edit

Created on 13 September 2019, about 5 years ago
Updated 28 February 2023, almost 2 years ago

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-&gt;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-&gt;onChange(&#039;default_langcode&#039;) (Line: 77)
Drupal\Core\TypedData\Plugin\DataType\ItemList-&gt;setValue(Array, 1) (Line: 107)
Drupal\Core\Field\FieldItemList-&gt;setValue(Array, 1) (Line: 628)
Drupal\Core\Entity\ContentEntityBase-&gt;set(&#039;default_langcode&#039;, Array) (Line: 328)
Drupal\Core\Entity\ContentEntityStorageBase-&gt;createRevision(Object, ) (Line: 294)
Drupal\content_moderation\EntityTypeInfo-&gt;entityPrepareForm(Object, &#039;edit&#039;, Object) (Line: 156)
content_moderation_entity_prepare_form(Object, &#039;edit&#039;, Object)
call_user_func_array(&#039;content_moderation_entity_prepare_form&#039;, Array) (Line: 408)
Drupal\Core\Entity\EntityForm-&gt;prepareInvokeAll(&#039;entity_prepare_form&#039;, Object) (Line: 139)
Drupal\Core\Entity\EntityForm-&gt;init(Object) (Line: 291)
Drupal\Core\Entity\ContentEntityForm-&gt;init(Object) (Line: 107)
Drupal\Core\Entity\EntityForm-&gt;buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 519)
Drupal\Core\Form\FormBuilder-&gt;retrieveForm(&#039;node_primer_page_edit_form&#039;, Object) (Line: 276)
Drupal\Core\Form\FormBuilder-&gt;buildForm(Object, Object) (Line: 93)
Drupal\Core\Controller\FormController-&gt;getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer-&gt;executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel-&gt;handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache-&gt;pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel-&gt;handle(Object, 1, 1) (Line: 697)
Drupal\Core\DrupalKernel-&gt;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

🐛 Bug report
Status

Closed: outdated

Version

10.1

Component
Entity 

Last updated about 12 hours ago

Created by

🇨🇭Switzerland berdir Switzerland

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇿New Zealand quietone

    I tested this on Drupal 10.1.x, standard install. I followed the steps in the issue summary, although I used a different 2nd and 3rd language. I was not able to reproduce the problem. No exception was thrown. However, the IS mentions a second bug, which I have confirmed. I searched for duplicates but did not find any. The bug is this part "related but less severe bug: the user is forwarded to en/node/X/latest, which is an access denied)". I have made a follow up for that part.

    Therefore, closing as outdated. If you are experiencing this problem on a supported version of Drupal reopen the issue, by setting the status to 'Active', and provide complete steps to reproduce the issue (starting from "Install Drupal core"). However, there are other issues concerning changing the default translation, so it would help everyone if you searched to see if another issue matches your situation better than this one.

    Thanks.

Production build 0.71.5 2024