Skip to content
Snippets Groups Projects

Draft: quick patch for surfacing/recording migrate_lookup stub row skips

Closed Adamo Maisano requested to merge issue/drupal-3447713:3447713-allow-migratestub-class into 10.4.x
@@ -109,7 +109,33 @@ protected function doCreateStub(MigrationInterface $migration, array $source_ids
$id_map = $migration->getIdMap();
$migrate_executable = new MigrateExecutable($migration);
$row = new Row($source_ids + $migration->getSourceConfiguration(), $migration->getSourcePlugin()->getIds(), TRUE);
$migrate_executable->processRow($row, $process);
try {
$migrate_executable->processRow($row, $process);
}
catch (MigrateSkipRowException $e) {
if ($e->getSaveToMap()) {
$id_map->saveIdMapping($row, [], MigrateIdMapInterface::STATUS_IGNORED);
}
if ($message = trim($e->getMessage())) {
// Figure out the destination key that failed:
$current_destination_key = [];
foreach ($process as $destination_key => $destination_value) {
if (!array_key_exists($destination_key, $row->getDestination())) {
$current_destination_key = $destination_key;
break;
}
}
$msg = sprintf("%s:%s: %s", $migration->getPluginId(), $current_destination_key, $message);
$id_map->saveMessage($row->getSourceIdValues(), $msg, MigrationInterface::MESSAGE_INFORMATIONAL);
}
return FALSE;
}
foreach ($default_values as $key => $value) {
$row->setDestinationProperty($key, $value);
}
Loading