Add per-entity-translation pre/post save methods (and hooks?) so that preSave() and postSave() implementations don't need to iterate all translations

Created on 30 September 2015, about 9 years ago
Updated 9 April 2023, over 1 year ago

Problem/Motivation

In #2474075: Fix Node::preSave() and document that preSave() and postSave() are not working with ContentEntity translations we agreed that we have an inconsistent API. While FieldItemListInterface::preSave() is called on every translation of a field, EntityInterface::preSave() is only called once on an entity before save, regardless of it's translations.

Proposed resolution

There're already exiting implementations of EntityInterface::preSave() that should not run multiple times per save. If we simply call EntityInterface::preSave() on every translation of en entity, these implementations need a switch to just be active on the default translation.
Therefor @catch proposed to consider to split this method into two. One that will be executed once and another that will be executed on every translation of the entity before save.

Remaining tasks

Decide about the best API.

User interface changes

None.

API changes

Sure ;-)

Data model changes

None.

📌 Task
Status

Needs work

Version

10.1

Component
Entity 

Last updated 4 minutes ago

Created by

🇩🇪Germany mkalkbrenner 🇩🇪

Live updates comments and jobs are added and updated live.
  • D8MI

    (Drupal 8 Multilingual Initiative) is the tag used by the multilingual initiative to mark core issues (and some contributed module issues). For versions other than Drupal 8, use the i18n (Internationalization) tag on issues which involve or affect multilingual / multinational support. That is preferred over Translation.

  • API addition

    Enhances an existing API or introduces a new subsystem. Depending on the size and impact, possibly backportable to earlier major versions.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024