Problem/Motivation

We need to skip recalculating of the revision translations if the entity is syncing and the existing revision is updated instead of creating a new one.
Useful for content import, migration, hook_update_N(), when we need to keep the revision_translation_affected field value for the old revisions.
Otherwise, it can break the list of revisions, e.g. /node/{nid}/revisions. This happens because ContentEntityStorageBase::populateAffectedRevisionTranslations() updates this field for all translations of the entity.

The issue could be as a second part of the #3052115: Mark an entity as 'syncing' during a migration update. That issue fixed the synchronization process for the revision migration. This one must fix an extra bug related to the revision_translation_affected base field.
But in general, it seems to have been missed in the ticket #2803717: Allow 'syncing' content to be updated in content moderation without forcing the creation of a new revision.

Steps to reproduce

A simple situation:

  • D9/10 site with minimum two languages. E.g. EN and FR.
  • Content type News with Publishing option: Create new revision.
  • Certain node was created and updated with scenario:
    • Created the node - EN lang - revisions id 1
    • Created a translation - FR lang - revisions id 2
    • Updated the node - EN lang - revisions id 3
    • Updated the node - FR lang - revisions id 4
    • Updated the node - EN lang - revisions id 5
  • In the result the /node/{nid}/revisions will show only the language-related revisions: 3 revisions for the EN lang and 2 for the FR
  • We added a new field Field A that related from the other.
  • We want to set the field for all old revisions according to some conditions.
  • To set the field we can use migration and entity_revision destination plugin or hook_update_N(). In both cases, the code $entity->setNewRevision(FALSE); $entity->setSyncing(TRUE); must be used.
  • As a result, we can see that the value of the new Field A has been added to each revision, on the revision page /node/{nid}/revisions

Proposed resolution

We have to make a solution that will allow skipping the updating of the revision_translation_affected for the old revisions and when we use the synchronization process.

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

It's good to use together with #3052115: Mark an entity as 'syncing' during a migration update when we need it for the migration.

Issue fork drupal-3338260

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

HitchShock created an issue. See original summary.

hitchshock’s picture

Status: Active » Needs work
StatusFileSize
new1.05 KB

Made a quick patch for that but tests are still required for this solution.

hitchshock’s picture

Issue summary: View changes

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

amateescu’s picture

Component: content_moderation.module » entity system
Issue tags: -migration, -revision moderation, -old revisions, -revisions, -synchronization

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.