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.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | skip_changing_affected_flag_3338260-2.patch | 1.05 KB | hitchshock |
Issue fork drupal-3338260
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:
- 3338260-skip-changing-revision
changes, plain diff MR !3353
Comments
Comment #2
hitchshockMade a quick patch for that but tests are still required for this solution.
Comment #4
hitchshockComment #6
amateescu commented