hasTranslationChanges on multiple languages outside of saving process is costly

Created on 16 October 2018, about 6 years ago
Updated 2 February 2023, almost 2 years ago

Problem/Motivation

Comment from @maximpodorov in #2833049-16: ContentEntityBase::hasTranslationChanges will compare a forward revision with the default one instead of the newest forward revision β†’ :

BTW, if ContentEntityBase::hasTranslationChanges() is called several times (e.g. for different languages) and (see its code) $this->original is not set, $original is loaded from the DB every time. I suggest to cache $original in the entity. This can be related to #2961399: Support parallel translation forward revisions on untranslatable fields

This is a problem only if hasTranslationChanges is called outside of a saving process, which currently is the case in two constraint validators:

  1. \Drupal\Core\Entity\Plugin\Validation\Constraint\EntityUntranslatableFieldsConstraintValidator::validate()
  2. \Drupal\content_translation\Plugin\Validation\Constraint\ContentTranslationSynchronizedFieldsConstraintValidator::validate()

Proposed resolution

  1. Set the original entity before calling hasTranslationChanges over multiple entity translations?
  2. Pass the original entity as an argument to hasTranslationChanges?

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Needs work

Version

10.1 ✨

Component
EntityΒ  β†’

Last updated about 17 hours ago

Created by

πŸ‡©πŸ‡ͺGermany hchonov πŸ‡ͺπŸ‡ΊπŸ‡©πŸ‡ͺπŸ‡§πŸ‡¬

Live updates comments and jobs are added and updated live.
  • 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

Merge Requests

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