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

Comments

hideaway created an issue. See original summary.

hideaway’s picture

Not sure if this is fully correct approach, but I use the following patch to prevent revision_id update for paragraphs.

hideaway’s picture

StatusFileSize
new2.16 KB

Previous patch was not correct, rolling a new one.

martin_klima’s picture

Many 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.

martin_klima’s picture

Status: Active » Needs work

Unfortunatelly, 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.

aludescher’s picture

This is patch from #3 with an isRevisionable() check (until there's a better solution mentioned in #5).

andrew answer’s picture

Priority: Major » Critical
Issue tags: -

Drupal 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.

ivnish’s picture

It will be fixed soon

miroslav-lee’s picture

Status: Needs work » Fixed

I have refactored the code and it should be fixed, please check it.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.