Problem/Motivation
Steps to reproduce:
- install Drupal
- enable Content translation (will enable Language module)
- add a language or two
- go to content translation settings under regional and language
- enable articles for translation with all defaults left intact (all fields except image files)
- go create an article
- translate the article to any other language (NOTE: the translated body will overwrite the original body)
- translate the article to one other language (NOTE: the translated body will again overwrite the original body)
Now you ended up with two translations of a node with all node views showing the last body value entered. If you look in the DB, the language code of the body field is the original language code of the node but the value is the last one entered in the last translation of the node. If you look into the configuration, the body field is marked as translatable (from content_translation.settings.yml):
...
node:
article:
content_translation:
enabled: true
fields:
title: true
body: true
comment: true
field_image: true
field_tags: true
...
Note the same problem does not apply to the tags field or the base fields (practically: title).
Proposed resolution
Make body properly translate again. Write tests.
Remaining tasks
Fix.
Write tests.
Review.
User interface changes
None.
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#13 | ct-settings_broken-2148795-13.patch | 6.22 KB | Gábor Hojtsy |
#6 | ct-settings_broken-2148795-4-fail.patch | 2.87 KB | plach |
Comments
Comment #1
Gábor HojtsyComment #2
webchickLet's get some tests for this.
Comment #3
plachOn this
Comment #4
plachThe problem is quite simple: we were not correctly handling configurable field translatability changes. This seems to happen only to node bodies because in the OP use case we have two bundles, but tags are attached only to articles. When saving the new settings the translatability status was saved for each bundle and the last one prevaled. Instead we need to save one global value for all field instances. As a bonus while testing this I found an additional bug in the Field UI field settings page and fixed that one too. Tests cover both.
Comment #5
plachComment #6
plachRe-uploading the test only patch (which is supposed to fail)...
Comment #8
swentel CreditAttribution: swentel commented@plach re: the Field UI bug you noticed, is that related with #1831608: Show or hide the "Make field translatable" checkbox on the add field form depending on translatability also ? Been trying to reroll that one yesterday but had weird test failures .. on the body .. :)
Comment #9
plach@swentel:
The body test failures might be related to the original issue here :) Not sure about the Field UI bug: we were not updating the CT settings, which will be the only one used to track translatability once we are done with the Field API refactorings.
Comment #10
plachComment #11
plachOk, we should be good here. Patch to review/commit is #4.
Comment #12
amateescu CreditAttribution: amateescu commentedIs there an existing issue we can point to here?
Comment #13
Gábor HojtsyThe patch looks complete. It has solutions for both the global setup form and the field level setup form. I also verified that the patch works with a simplytest.me instance (set up an article and verified body translatability). Uploading a minimally modified version which qualifies that @todo with a link to #2018685: Remove field_is_translatable() which I believe is the best place to link this. I think this should be ready to go.
Comment #14
amateescu CreditAttribution: amateescu commentedRTBC++ :)
Comment #15
plachRTBC++ :)
Comment #16
webchickAwesome, thanks for the extra test coverage here.
Committed and pushed to 8.x. Thanks!
Comment #17
plachAwesome, thanks!
Comment #19
Gábor HojtsyThat was due to being unable to apply patch.