Problem/Motivation

Since #2143291: Clarify handling of field translatability
a few fields are missing from the content translation overview for article, admin/config/regional/content-language
comment settings
image file
tags

Steps to reproduce

To get right before: git checkout -b before 0f752ca6091259af20300ef8d156caa1daea6088
To get right after: git checkout -b after 86e432e05ea1493f0c7cd053470ba676cf2fe7fe

  1. Install
  2. Install (Enable) content translation module
  3. Add a language
  4. Go to admin/config/regional/content-language
  5. Check content, and article

Proposed resolution

in #2143291: Clarify handling of field translatability, there was a true/false reversal and it missed a few places, in standard profile node default config, and also in the code for comment settings.
the fix here takes care of those true/false's, and also adds a test.

Remaining tasks

  • (done) Find out what the actual problem is
Contributor tasks needed
Task Novice task? Contributor instructions Complete?
Create a patch Instructions done
Update the issue summary Instructions done
Add automated tests Instructions done
Improve patch documentation or standards (for just lines changed by the patch) Novice Instructions done
Manually test the patch Novice Instructions done
Add steps to reproduce the issue Novice Instructions done
Embed before and after screenshots in the issue summary Novice Instructions done
Review patch to ensure that it fixes the issue, stays within scope, is properly documented, and follows coding standards Instructions

User interface changes

No. just fix the regression.

Before in comment #1

After

after shows the fields there

API changes

No.

Comments

yesct’s picture

Title: Regression: File missing from tranlsation overview since Clarify handling of field translatability » Regression: Fields missing from tranlsation overview since Clarify handling of field translatability
Issue summary: View changes
StatusFileSize
new432.51 KB

Noticed while working on #1920876: Add a tiny bit of state magic in the image.module and hide the Title and Alt groups when the related form items are disabled

showing before and after the issue

issue probably needs a new title once we figure out what is going on.

missing fields are:
Comment settings
File (image)
Tags

I know adding a new simple text field does show.

gábor hojtsy’s picture

Priority: Normal » Critical

Raising to critical.

berdir’s picture

Can you check if a manually added image field does show up?

If that works, then I guess this the default configuration fiels have not been updated, field.field.node.field_image.yml in standard/config/install says translatable: false, but I think that should now be translatable: true.

Try changing that and re-install.

That said, if this is the case, then this is really just a normal bug and easy to fix, regressions are not per se critical (anymore).

yesct’s picture

Yes, fields added via the UI do show.

gábor hojtsy’s picture

For the default setup, only the body field is configurable as translatable and it DOES have the translatable checkbox checked but disabled on the field UI (with a description that it needs to have language support for the entity first to have translatability configuration). Is probably somehow related :)

gábor hojtsy’s picture

Assigned: Unassigned » yesct
Priority: Critical » Normal

So YesCT is working on this. Also demoting per #3.

gábor hojtsy’s picture

Title: Regression: Fields missing from tranlsation overview since Clarify handling of field translatability » Regression: Fields missing from translation overview since "Clarify handling of field translatability"

Fix typo in title.

yesct’s picture

Status: Active » Needs review
StatusFileSize
new996 bytes

this does make the tags and image file show.
looking into how to change the setting for comments.

@franSeva is also working on this in irc

yesct’s picture

StatusFileSize
new1.55 KB
new589 bytes

@Gábor Hojtsy helped me in irc find where the comment setting was coming from.

reinstalling with these settings does make the fields show in the overview.

attaching new patch and interdiff.
Still waiting for the test from @franSeva

===============

However, I'm still concerned that the config is being saved for instances with translatable false.
This is concerning because 1) it should be true.
And, if it is false... then why are they being shown as translatable (checked) in the overview.

I installed the config_devel module
and then in
sites/default/files/config_devel
ag "translatable: false"
gives

field.field.user.user_picture.yml
28:translatable: false

field.instance.block_content.basic.body.yml
16:translatable: false

field.instance.comment.comment.comment_body.yml
16:translatable: false

field.instance.node.page.body.yml
16:translatable: false

(user picture is fine. As I understand it... it should be false.)

[edit: added...}

From the db, at first I thought the data was binary, cause phpmyadmin said it was, but when I saved the "bin" file, and opened it, it was readable text with:
s:12:"translatable";b:1;
b must be boolean
and...
0 is false
1 is true
so in the db, it's true

why when it writes out the yml is it false?
I tried tracking down how yml gets saved... and haven't yet had luck.

fran seva’s picture

@YesCT oki. I'm on it :)

yesct’s picture

Assigned: yesct » Unassigned

I'll check back in on this later, especially to see if anyone has ideas about the config saving wrong.

plach’s picture

However, I'm still concerned that the config is being saved for instances with translatable false.
This is concerning because 1) it should be true.
And, if it is false... then why are they being shown as translatable (checked) in the overview.

In #2143291: Clarify handling of field translatability we introduced two distinct concepts around field translatability:

  • The translatable property of field storage definitions (FieldConfig) determines whether the field supports translation, this in turn determines whether the fields appears in the content translation settings page.
  • The translatable property can be overridden for each field definition (FieldInstanceConfig), and thus can have per-bundle granularity. This determines whether the field is enabled for translation (checkbox on/off by default). Please note that you can override the storage definition value from TRUE to FALSE, but not the opposite, as you can't force a field to be translatable if its storage does not support multilingual values.

To sum up the desired (and hopefully implemented :) behavior for configurable fields is:

  • the field storage definition is TRUE by default
  • the Field UI creates field definitions with translatable value FALSE by default

We probably forgot to move the translatable: false line from the FieldConfig file to the FieldInstanceConfig file in those cases.

Since we are addressing this, we should also check whether comment settings actually work correctly when the field is set to translatable, that is we should check whether we can open/close comments independently for each language. If not we should mark them as translatable: false here, and file a separate bug report to address that.

yesct’s picture

side note I should open an issue about:
I think that translatable property should be renamed to supportsTranslation (and method isTranslatable() to supportsTranslation() ) for the field definitions.
and we keep translatable and isTranslatable() for the instances.
------

Seems to me that via the UI:
creating, for example, an image file field,

1) that that field definition is translatable true (supportsTranslation), because ... image file fields by default are/do. (and nothing can change whether it supports translation or not)

and

2) that the specific instance of that field created via the UI is initially translatable false, because it has yet not been set to be translatable.

3) but that once the instance *is* set to be translatable, that exporting the config for that instance, should include the fact that it is translatable. (it's translatable in the database)

hmm...
How are other instance settings saved? Like the cardinality, or default value, or allowed values? seems like translatable would be similar

yesct’s picture

Sorry, I think I didn't understand what "instance" meant.

field.instance.comment.comment.comment_body.yml

uuid: 8902af40-2297-44ef-b52a-4271948de4cc
langcode: en
status: true
dependencies:
  entity:
    - comment.type.comment
    - field.field.comment.comment_body
id: comment.comment.comment_body
label: Comment
field_uuid: f86f0984-81c3-4120-af01-1e2b8d64cbb0
field_name: comment_body
entity_type: comment
bundle: comment
description: ''
required: true
translatable: false
default_value: {  }
default_value_function: ''
settings:
  text_processing: '1'
  translation_sync: false
field_type: text_long

field.field.comment.comment_body.yml

uuid: f86f0984-81c3-4120-af01-1e2b8d64cbb0
langcode: en
status: true
dependencies:
  module:
    - comment
    - text
id: comment.comment_body
name: comment_body
entity_type: comment
type: text_long
settings:
  translation_sync: ''
module: text
locked: false
cardinality: 1
translatable: true
indexes: {  }

does have translatable true...

[edit...]

field.instance.node.article.comment.yml

uuid: 00e655c0-ea28-46d8-b508-8f741b7001a9
langcode: en
status: true
dependencies:
  entity:
    - field.field.node.comment
    - node.type.article
id: node.article.comment
label: 'Comment settings'
field_uuid: ed263fa2-cd72-44ed-9b00-b7dfe6ef43e7
field_name: comment
entity_type: node
bundle: article
description: 'The text I want.'
required: true
translatable: true
default_value:
  -
    status: 2
    cid: 0
    last_comment_timestamp: 0
    last_comment_name: null
    last_comment_uid: 0
    comment_count: 0
default_value_function: ''
settings:
  comment:
    default_mode: 1
    per_page: '50'
    anonymous: 0
    subject: 1
    form_location: 1
    preview: '1'
  default_mode: true
  per_page: 50
  form_location: true
  anonymous: 0
  subject: true
  preview: 1
  translation_sync: false
field_type: comment

field.field.node.comment.yml

uuid: ed263fa2-cd72-44ed-9b00-b7dfe6ef43e7
langcode: en
status: true
dependencies:
  module:
    - comment
    - node
id: node.comment
name: comment
entity_type: node
type: comment
settings:
  comment_type: comment
  translation_sync: ''
module: comment
locked: false
cardinality: 1
translatable: true
indexes: {  }

[edit again]
why, though, is
field.instance.node.article.field_image.yml
translatable: true

and field.field.node.field_image.yml
also
translatable: true
?

fran seva’s picture

@YestCT attach the first version of the test.
The test is wrong but the xpath are correct I've checked with chrome console.

gábor hojtsy’s picture

@fran seva: you are testing fields that are not actually added by the test. The test manually creates the content types and only adds the comment field, not the image field or the tags field. Even if it would add those fields, it would be dynamically added and therefore the test would not test the actual defaults in the standard profile. The fix patches runtime code in the comment.manager, which the test in fact uses to create the comment field, so the test is correct for that in fact, but not for the tags or the image field.

yesct’s picture

maybe... @plach is saying that in
./core/profiles/standard/config/install/field.instance.node.article.field_image.yml
it should have a
translatable: false
?

(right now, there is no translatable: ... in there)

yesct’s picture

StatusFileSize
new206.47 KB

So, /admin/config/regional/content-language
is about content translation, not config translation.

So maybe comment settings should *not* be listed there. (and should not have been *before*), and should be translatable false.

If people want to say that the comments on articles are translatable, then they would use
the comment element to Custom language settings:

For image fields, we dont have title or alt enabled or disabled per language (in core) so we probably shouldn't for comment settings (for content translation).
Config translation would/should probably handle any parts of the comment settings that should be translatable, like the label or the help text.

berdir’s picture

@YesCT: Comment settings is the *field* that stores the per-node (or other entity) comment settings, meaning, if commenting on that article is open/closed/hidden. This is content.

Making that translatable would mean that it should be possible to for example allow comments on the german original entity but not allow it on the english translation. The qestion is if that actually works, which should be tested. Only if not should it be set to translatable: false in the field because it would not work. But it seems like a useful feature to me.

Status: Needs review » Needs work

The last submitted patch, 15: 2290849-testFieldTranslatableArticle-15.patch, failed testing.

plach’s picture

@YesCT:

side note I should open an issue about:
I think that translatable property should be renamed to supportsTranslation (and method isTranslatable() to supportsTranslation() ) for the field definitions.
and we keep translatable and isTranslatable() for the instances.

Please no. We already discussed this extensively in #2143291: Clarify handling of field translatability. We are applying to the translatable property a pattern that is valid for most of the other field properties (except those that cannot be overridden). I don't think special-casing it makes any sense or would be a DX improvement in the long run. Translatable means translatable. There are just different nuances depending on context, but I think that once you grasp the difference between storage field definition and field definition, it becomes immediately clear what the translatable property means in the two contexts.

andypost’s picture

Comment settings is the *field* that stores the per-node (or other entity) comment settings, meaning, if commenting on that article is open/closed/hidden

So \Drupal\comment\Plugin\Field\FieldType\CommentItem::__get() should be tuned to properly use default value for translation

berdir’s picture

That shouldn't be necessary, the default value there is not translatable right now afaik, and if it would be, then that would be config translation and just work as you would get the translated config entity.

fran seva’s picture

StatusFileSize
new2.24 KB

Attach the new test to check are presents the followings checkboxes in [1].
I'm not sure about the naming in functions and the class.

[1] /admin/config/regional/content-language

fran seva’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 24: 2290849-testFieldTranslatableArticle-24.patch, failed testing.

yesct’s picture

super! the test actually fails where we want it to. :)

Talked to @fran seva in irc, and they are going to post an updated test with a rename, and few nit fixes, the interdiff for those changes, and also a combined fix and test patch. :)

fran seva’s picture

@YesCT attach :
- test
- test interdiff
- merge between issue patch and test patch.

fran seva’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 28: 2290849-testFieldTranslatableArticle-28.patch, failed testing.

fran seva’s picture

StatusFileSize
new2.8 KB
fran seva’s picture

@YesCT Change the typo and the array indentation.
I have run phpcodesniffer and there are no error or warnings

fran seva’s picture

Status: Needs work » Needs review
yesct’s picture

Issue summary: View changes
Issue tags: -Needs tests
StatusFileSize
new148.64 KB

I went back and looked at the site config export. I think it is being saved ok, (with the patch) with translatable: true in the right places. (given my new understanding of field.field.... )

Also, I did the manual testing:
the comment setting (open, closed, hidden) *can* be set per language for a node. (except for #2294159: Translations of nodes with comment settings field set to translatable are missing hidden choice). disabling translation on the comment settings, and then re-enabling it: each translation remembers its old setting. which was nice.

Taking off the needs test tag, as we had the 3 fails without the fix, and with the fix and test, we have all passes. So I think that is ok.

Updated issue summary

Next here: a (final-ish) review.

yesct’s picture

Issue summary: View changes

issue summary html fix

plach’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/core/modules/comment/src/CommentManager.php
@@ -132,7 +132,7 @@ public function addDefaultField($entity_type, $bundle, $field_name = 'comment',
+        'translatable' => TRUE,

Technically speaking I think we could just remove this line as TRUE is the default, but making that explicit won't hurt :)

Good work, thanks!

gábor hojtsy’s picture

Priority: Normal » Major

The bug is a major issue. The fix is simple.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Great work, folks! Nice to have test coverage for this.

Committed and pushed to 8.x. Thanks!

  • webchick committed 75346a3 on 8.x
    Issue #2290849 by fran seva, YesCT: Fixed Regression: Fields missing...
andypost’s picture

+++ b/core/modules/comment/src/CommentManager.php
@@ -132,7 +132,7 @@ public function addDefaultField($entity_type, $bundle, $field_name = 'comment',
+        'translatable' => TRUE,

I seriously recommend to turn this back to FALSE because comment thread is not language depended

The follow-up discussion in #2294159: Translations of nodes with comment settings field set to translatable are missing hidden choice

gábor hojtsy’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.