Closed trackleft closed 5 months ago
Would it be reasonable to maybe include a check during the migration script? As it's going through and working on the entity embeds, can we first include a check for something along the lines of ! if file exists
on the source site, and if the file doesn't exist, then don't include the embed?
Possibly add try catch to skip creating a stub.
Also remove and replace drupal-entity element with <h1>entity no longer exists</h1>
Searchable using drupal search ^
Seems related: https://www.drupal.org/project/drupal/issues/3156730
To bypass this if you do not need stubs you can change https://github.com/az-digital/az_quickstart/blob/main/modules/custom/az_migration/src/Plugin/migrate/process/EntityEmbedProcess.php#L164-L178 To
if (empty($ids)) {
// $ids = $this->migrateStub->createStub($migration, [$id], $stub_defaults);
$ids = "deleted_file";
}
// We eventually found our id, by lookup or stubbing it.
if (!empty($ids)&&is_array($ids)) {
$id = reset($ids);
if (!empty($id)) {
$eid = reset($id);
$entity = $this->entityTypeManager->getStorage($storage)->load($eid);
if ($entity) {
$changed->setAttribute('data-entity-uuid', $entity->uuid());
}
}
}
else {
$changed = $dom->createElement("h1", "deleted_entity");
}
New patch: Note: This patch will stop stub creation for embedded entities, so if you need that you need to use another approach.
"patches": {
"az-digital/az_quickstart" {
"Migration fails on stub creation when source site has deleted entity embedded in content.(https://github.com/az-digital/az_quickstart/issues/1740)": "https://patch-diff.githubusercontent.com/raw/az-digital/az_quickstart/pull/1799.diff"
}
}
Remove this patch when done with your migration.
If you run into issues with this patch, please report them on this issue.
As far as we know this is no longer an issue. Issue can be re-opened if still affecting anyone.
Problem/Motivation
Would like migrations to run more smoothly
Describe the bug
Receive
Call to a member function getSource() on null in Drupal\media\Entity\Media->getSource()
To Reproduce
Source site: Create source site with QS1 codebase Add media to be embedded Create page Add headed text paragraph to page Embed the media Save Go delete the media
Destination Site Set up site to be able to migration from the source site. Run the az_migration group
Proposed resolution
Found this issue on drupal.org about it. https://www.drupal.org/project/migrate_file_to_media/issues/3138268#comment-13669457
Possibly could be fixed by adding default values for bundle to the createStub call
https://github.com/az-digital/az_quickstart/blob/main/modules/custom/az_migration/src/Plugin/migrate/process/EntityEmbedProcess.php#L165-L167
https://api.druphelp.com/api/drupal/core%21modules%21migrate%21src%21MigrateStub.php/function/MigrateStub%3A%3AcreateStub/9