Problem/Motivation
I have set up a migration in 2 steps:
* first migrate data from Drupal 6 into a paragraph entity_reference_revisions entity (with the destination plugin 'entity_reference_revisions:paragraph')
* Secondly assign this paragraph to a parent node (by doing a lookup with the migrate process plugin) - as described in this issue: #2809793: EntityReference migrate destination
This works well. My paragraphs get migrated, and subsequently assigned to the parent node.
However I noticed an edge case which causes problems. If a node gets deleted (either manually or by rolling back the migration for that node type), the linked paragraphs also get deleted.
When I then try to do a migration rollback on the paragraphs migration, I get the following error:
Error: Call to a member function isDefaultRevision() on null in Drupal\entity_reference_revisions\Plugin\migrate\destination\EntityReferenceRevisions->rollbackNonTranslation() (line 144 of [error]
web/modules/contrib/entity_reference_revisions/src/Plugin/migrate/destination/EntityReferenceRevisions.php) #0
Proposed resolution
* Add an extra check in the rollback() function of the migrate destination plugin, to make sure the entity that is about to be deleted, does actually (still) exist.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 2841650-2.patch | 902 bytes | svendecabooter |
Comments
Comment #2
svendecabooterAttached is a patch that fixes the fatal errors and lets the rollback process finish.
Comment #4
trevorbradley commentedCoincidentally, just struggling with this same problem this afternoon, migrating using migrate_source_csv. (Most of the server OSs that run D6 sites are hitting EOL, must be that time of the year...)
Running a "drush mr" on the content type means that the attached paragraphs cannot be rolled back (with this identical error: Line 144 of EntityReferenceRevisions.php).
You can run
to work around the error (re-importing the entire paragraphs).
EDIT: Let me try this patch out...
Comment #5
trevorbradley commentedThe patch works lovely as best I can tell. No clue about that Test error - my PHP Unit is throwing an error of:
Comment #6
svendecabooterThanks for the review!
The PHPUnit error does seem unrelated, but I suppose maintainers have a better view on that.
Comment #7
kil commentedI'm also running into this problem when migrating data into D8 from an external not Drupal database. I can also confirm, that the patch solves the error when doing a rollback of the 'entity_reference_revisions:paragraph' migration (that is the first step of the migration as described by svendecabooter).
But it seems to me that the problem goes deeper: With the rollback of the 'entity:node' (that is the second step as described by svendecabooter) the paragraphs are deleted but migration is not informed about this (no update of the migrate_map). So migration still believes that the paragraph data is present (you can see in the migrate status for the first step that the data is marked as imported). I need to do a rollback of the first step, before I restart the second step migration, although migration status tells me that everything is imported. Otherwise the second step migration will run (and migration_dependencies is also not working, because migrate_map tells that everything is imported) but it will not apply the paragraphs data (as this data is not present anymore). As TrevorBradley pointed out, you need a re-import of the entire paragraphs. This may be no problem as long as you group your migrations and run rollback and migration for the whole group, but handling a lot of data with many migrations (and being in the process of testing the migration steps) I usually start and rollback migrations individually. In such a case the data can get a little bit of a mess if you not pay attention of this rollback relation between the first and the second step. Maybe someone has an answer for this problem (somewhere migrate_map needs to be updated)?
Comment #9
miro_dietikerCommitted, thx. :-)