content_translation.synchronizer fails to create a new translation on fields using column_groups

Created on 16 December 2024, 4 months ago

Problem/Motivation

Fields can declare column_groups to allow setting some of their properties as translatable.
This has no usage in Core for now but might be happening with Allow to configure translation per property on link fields (for translating only the title, not the url itself) Postponed: needs info someday.

When using this kind of field on a new translation, \Drupal\content_translation\FieldTranslationSynchronizer::synchronizeFields(), called by content_translation_entity_presave(), throws an exception while trying to get the translation on the original entity without checking if it has one or not.

While trying to understand the issue, I realized that the only test on this method was from \Drupal\Tests\content_translation\Kernel\ContentTranslationFieldSyncRevisionTest::testFieldSynchronizationAndValidation() and that it doesn't seem to really cover this specific case.

Steps to reproduce

I faced this issue using the above patch and translating entities containing link fields with TMGMT.
I don't know how to reproduce on a Vanilla Drupal.

Proposed resolution

Check if the translation exists before trying to get it. In case it doesn't, use the source entity to get fields values.

🐛 Bug report
Status

Active

Version

11.1 🔥

Component

content_translation.module

Created by

🇫🇷France duaelfr Montpellier, France

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024