Hello. We are experiencing a problem, basically, there is a json file with a lot of articles to import, and 'langcode' is provided with them. But when setting the langcode in the mapper, sometimes, it will throw "this field cannot hold more than 1 values", this happens when updating an already existing article.
Steps to reproduce:
- Set the mapper normally
- Set a target for 'langcode' to a language
- There must be a target for a translatable field with its language different than the 'langcode' target
- Import.
- Now, if it finds an already existing entity, it will throw this error
I will upload a patch, but I don't think it is the best solution right now. Also, I'm not sure if this counts as a bug or a feature.
Comments
Comment #2
yahyaalhamadThis is the patch, hopefully, it will pass the automated tests.
Comment #3
yahyaalhamadMade a mistake, forgot that my code is commented out.
Comment #4
yahyaalhamadComment #5
yahyaalhamadIt seems sometimes, on fields with default values, this error will be thrown. This is a hotfix patch for now. until we find the reason why it happens exactly. Interdiff included.
Comment #6
thomaswalther commentedI testet patch #5. I do not get any errors like before (#3201596: How to import JSON files, one for each language).
But the first imported german node is gone, and was replacing through the english version.
Comment #7
pons_vs commentedI tried this patch #5 but it is not working. It is showing this error
"Warning message
The content Test Real Content failed to validate with the following errors:
: Non-translatable fields can only be changed when updating the original language."
I'm trying to import the multilingual content so created two feed types one is for english language and anthoer one is for russian language First I've imported en language content then trying to import the next language with same nid but it is not working.My sample csv file for both languages
ID,Title,Cover_image,Category,Moderation_state
5721,Test Real Content,2,Parenting Corner,draft
Comment #8
andrew answer commentedHello, I found that language field of target entity have the language code and solves the problem. I prepare the patch for this.
Comment #9
andrew answer commentedComment #10
kristen polThanks for the new patch. Tagging for tests to be created.
Comment #11
audacus commentedI ran into the same error ("this field cannot hold more than 1 values") but not on the "langcode" field.
The error occurred for every field that I wanted to import in another language.
I have 12 fields of which 4 shall be imported in another language (total 16 mappings).
The error occurred because in
FieldTargetBase::setTarget()it tried to merge the values of the different languages into the same field.So I just applied a certain snippet of the patch #5 which implements checking for
isMultiple()on the field when setting the value.This solved my problem
I didn't test how it behaves for multivalue fields that are translatable.
Comment #12
spadxiii commentedRan into a little issue using #5 where the mapped langcode was an array with 'nl' as value. Updated the patch from #5 with an extra check.
Comment #13
hswong3i commentedPatch re-roll from #12 via 8.x-3.x-dev
Comment #14
spadxiii commentedPatch re-roll from #12
 for 8.x-3.x-dev
Comment #15
hswong3i commentedPatch re-roll from #14 via 8.x-3.x-dev
Comment #16
hswong3i commentedPatch re-roll from #15 via 8.x-3.x-dev and convert as PR
Comment #18
ahmad khader commentedAdded PR as patch
Comment #19
megachrizTagging with "multilanguage"
Comment #20
baikho commentedI tested patch from #18 on v3.0.0, but that is still reproducing the behaviour as described in #6
Or what I think is happening is that the original source node's language get swapped with the overridden language instead.
Comment #21
baikho commented