Problem/Motivation
Updating an entity whose language differs from the processor language keeps the old values next to the imported ones, so single-value fields fail validation (this field cannot hold more than 1 values).
EntityProcessorBase::clearTarget() clears the translation in the processor language when the mapping has no language, while FieldTargetBase::setTarget() writes to the default translation.
Earlier work on clearTarget() did not change which translation it clears (#3155046: Single Value (1) Image field importing as Multiple Values in Feeds , #3356227: Move clearing the target from the processor to the target plugin). The open MR on #3371339: Published state for translated node only covers translations created during an import.
Steps to reproduce
- On Drupal 11.4 with Feeds 8.x-3.x, enable Language and Content Translation, add Dutch, and make the Article bundle translatable.
- Create a CSV feed type for articles with the processor language English, "Update existing content" enabled, and a guid and title mapping without a language.
- Have an existing Dutch article linked to the feed item. The added kernel test creates one directly.
- Import a CSV with that item and a changed title.
- The article is not updated because its title now holds two values.
Proposed resolution
This MR only switches to a translation in clearTarget() when $target->isTargetTranslatable() is TRUE, so it clears the translation that setTarget() writes to. Mappings with a language on a translatable field behave as before. A language on a field that is not translatable now clears the default translation, which no test covers. The two added kernel tests fail without this change.
User interface changes
None.
Introduced terminology
None.
API changes
None.
Data model changes
None.
Release notes snippet
None.
AI disclosure: This contribution was human-driven, AI-assisted, human-reviewed and tested in a real project.
Issue fork feeds-3628836
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