You may get undesired revision_id values for particular entities if you run import more than once.
In our case this is happening for paragraph entities which are configured as entity reference revisions for nodes. Basically, the node entity has a field (called field_paragraphs) which is entity reference revision field type (allowing paragraph entities only).
Now we are trying to import a simple node with one paragraph. For the simplicity, imagine the following starting conditions:
1. Node has an id of 1 and revision id of 1 as well
2. Paragraph has an id of 1 and revision id of 1 as well
3. Paragraph is referenced from node via field_paragraphs
Everything is ok after first import. But after second one the revision_id of paragraph entity is increased (being 2) and thus not matching the value from json file. Additionally, the revision id for node field where this paragraph is referenced stays the same (it stays 1). So the tables are having the following values:
- node__field_paragraphs table stores revision_id of 1
- paragraphs_item_field_data table stores revision_id of 2
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 2999955-6-do-not-update-revision-id-if-not-necessary.patch | 2.29 KB | aludescher |
| #3 | 2999955-3-do-not-update-revision-id-if-not-necessary.patch | 2.16 KB | hideaway |
Comments
Comment #2
hideaway commentedNot sure if this is fully correct approach, but I use the following patch to prevent revision_id update for paragraphs.
Comment #3
hideaway commentedPrevious patch was not correct, rolling a new one.
Comment #4
martin_klimaMany thanks for detailed explanation and patch. I think this problem caused the errors during import, which was reported many months ago. I have tried to reproduce that errors related to entity revision keys duplicity several hours, but with no success.
I tested your patch and can confirm the revision_ids remain the same during repeated import.
Comment #5
martin_klimaUnfortunatelly, the solution works only until source paragraph is updated.
When you export updated paragraph, it has incremented revision id. Your condition
$is_same_revision = $current_entity->getRevisionId() == $entity->getRevisionId();will be FALSE and since that time the revision id in paragraphs_item_field_data table will be incremented during each import.I think we need some another approach.
Comment #6
aludescher commentedThis is patch from #3 with an isRevisionable() check (until there's a better solution mentioned in #5).
Comment #7
andrew answer commentedDrupal 8.7.x have revisionable taxonomy terms. So right restoring terms from files is critical. I think for this case we need to have functional test coverage.
Comment #8
ivnishIt will be fixed soon
Comment #9
miroslav-leeI have refactored the code and it should be fixed, please check it.