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:

  1. Set the mapper normally
  2. Set a target for 'langcode' to a language
  3. There must be a target for a translatable field with its language different than the 'langcode' target
  4. Import.
  5. 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.

Issue fork feeds-3189557

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

YahyaAlHamad created an issue. See original summary.

yahyaalhamad’s picture

StatusFileSize
new3.21 KB

This is the patch, hopefully, it will pass the automated tests.

yahyaalhamad’s picture

StatusFileSize
new3.17 KB

Made a mistake, forgot that my code is commented out.

yahyaalhamad’s picture

StatusFileSize
new4.28 KB
new1.01 KB

It 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.

thomaswalther’s picture

I 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.

pons_vs’s picture

I 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

andrew answer’s picture

StatusFileSize
new824 bytes

Hello, I found that language field of target entity have the language code and solves the problem. I prepare the patch for this.

andrew answer’s picture

Status: Active » Needs review
kristen pol’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests, +ContributionWeekend2022

Thanks for the new patch. Tagging for tests to be created.

audacus’s picture

StatusFileSize
new961 bytes

I 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.

spadxiii’s picture

StatusFileSize
new4.39 KB
new732 bytes

Ran 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.

hswong3i’s picture

StatusFileSize
new4.43 KB

Patch re-roll from #12 via 8.x-3.x-dev

spadxiii’s picture

StatusFileSize
new4.43 KB

Patch re-roll from #12&#13 for 8.x-3.x-dev

hswong3i’s picture

StatusFileSize
new4.48 KB

Patch re-roll from #14 via 8.x-3.x-dev

hswong3i’s picture

Patch re-roll from #15 via 8.x-3.x-dev and convert as PR

ahmad khader’s picture

StatusFileSize
new5 KB

Added PR as patch

megachriz’s picture

Issue tags: +multilanguage

Tagging with "multilanguage"

baikho’s picture

I tested patch from #18 on v3.0.0, but that is still reproducing the behaviour as described in #6

But the first imported german node is gone, and was replacing through the english version.

Or what I think is happening is that the original source node's language get swapped with the overridden language instead.