Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
field level language are not correct handled
Proposed resolution
See patch
Remaining tasks
Wait for core : #1439692: Rename field language properties to langcode to land?
Original report by cutesquirrel
I have fields of type "taxonomy_term_reference" and field collections containing "taxonomy_term_reference".
With the joined patch, generated nodes contains selected terms in "taxonomy_term_reference" fields.
I'm not sure it's enough : I'm using taxonomy vocabularies with 'localize' translation mode.
Comment | File | Size | Author |
---|---|---|---|
#10 | respect-field-translatability-1292294-10.patch | 636 bytes | clemens.tolboom |
#6 | respect-field-translatability-1292294-6.patch | 880 bytes | Pisco |
#4 | respect-field-translatability-1292294-4.patch | 873 bytes | Pisco |
#2 | respect-field-translatability-1292294-2.patch | 914 bytes | Pisco |
devel_generate.fields.inc_.20110927.patch | 922 bytes | cutesquirrel | |
Comments
Comment #1
salvisPatches must go against the current -dev version.
Please respect the Drupal coding conventions:
No trailing spaces.
Comments start with a capital letter and end with a dot.
No leading space inside parenthesis.
Use '||' rather than 'or'.
Finally, mark you issue "needs review."
Comment #2
Pisco CreditAttribution: Pisco commentedThis is indeed a bug. As of D7 there are fields that can be translated and others that can not be translated. devel_generate does not respect this at the moment. As a consequence, when generating content that has a language, in a content type that has fields which can not be translated, the generated values get lost during
node_save
. Each field instance has meta data telling wether it can or can not be translated, this simple patches fixes that issue while respecting the translatability of a field.@cutesquirrel, your approach is wrong because it doesn't solve the problem in a generic way. taxonomy_term_reference is in no way special, thus in devel_generate there should not be special code for it. Have a look at my patch for a generic approach.
Comment #3
moshe weitzman CreditAttribution: moshe weitzman commentedCommitted to 7.x but failed to apply to 8.x. Could anyone reroll for 8?
Comment #4
Pisco CreditAttribution: Pisco commentedThanks for committing! This patch should work for the 8.x branch.
Comment #5
salvisIs this correct PHP? What's the meaning of
$object->{'foo'}{'bar'}
? Shouldn't this have been
$object->{'foo'}['bar']
? Or in our case
$object->{$field_name}[$object->language]
and thus become
$object->{$field_name}[$field['translatable'] ? $object->language : LANGUAGE_NONE] = $object_field;
?
(double space in ternary operator)
Comment #6
Pisco CreditAttribution: Pisco commentedThanks for the review @salvis, here's another try.
Comment #7
blackandcode CreditAttribution: blackandcode commented#6: respect-field-translatability-1292294-6.patch queued for re-testing.
Comment #8
salvisLooks good now, still needs review and testing...
Comment #9
clemens.tolboomPlease split this into two lines. That's way more readable :)
Comment #9.0
clemens.tolboomUpdated issue summary.
Comment #10
clemens.tolboomI added one comment and split into two lines of code.
This break as soon as core : #1439692: Rename field language properties to langcode lands.
Comment #11
clemens.tolboomComment #12
salvis@clemens.tolboom: Thanks for working on the patch and for the heads up about langcode. Let's keep this separate, because the patch resulting from this issue here should still apply to D7, too.
@All: please review and test...
Comment #13
salvis#10: respect-field-translatability-1292294-10.patch queued for re-testing.
Comment #14
salvisI wish someone would have tested this...
The automated test says very little unfortunately, except that the patch still applies.
#10 is still intended to be applied to the D7 version, and we need an update for D8.
Comment #15
clemens.tolboom@salvis #10 is for D8 :)
The patch applies probably as there are no tests written hitting this patch. But it will break locally now I guess.
So this needs review.
Comment #16
salvisI think we have a more comprehensive patch here: #1549662: Node, taxonomy, comment, and user are all classed objects — I'd like to get that one committed and then see what's left.
Comment #17
salvisThis needs re-rolling after #1549662: Node, taxonomy, comment, and user are all classed objects.
Comment #18
salvis#10: respect-field-translatability-1292294-10.patch queued for re-testing.
Comment #19.0
(not verified) CreditAttribution: commentedUpdated issue summary.
Comment #20
moshe weitzman CreditAttribution: moshe weitzman commentedThis is very old. Please open a new issue if this is still a problem.