Commit 56507636 authored by catch's avatar catch

Issue #2682705 by davidwbarratt, alexpott, vprocessor, miiimooo, milesw:...

Issue #2682705 by davidwbarratt, alexpott, vprocessor, miiimooo, milesw: Migrate process plugin does not save stubs to the idmap, leads to duplicates and broken references
parent f5f64799
......@@ -11,6 +11,7 @@
use Drupal\migrate\MigrateSkipProcessException;
use Drupal\migrate\Plugin\MigratePluginManager;
use Drupal\migrate\Plugin\MigrationPluginManagerInterface;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\MigrateExecutableInterface;
......@@ -139,7 +140,11 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
$destination_ids = $destination_plugin->import($stub_row);
}
catch (\Exception $e) {
$migrate_executable->saveMessage($e->getMessage());
$migration->getIdMap()->saveMessage($stub_row->getSourceIdValues(), $e->getMessage());
}
if ($destination_ids) {
$migration->getIdMap()->saveIdMapping($stub_row, $destination_ids, MigrateIdMapInterface::STATUS_NEEDS_UPDATE);
}
}
if ($destination_ids) {
......
......@@ -67,6 +67,7 @@ public function testTransformWithStubbing() {
$migration_plugin_manager->createInstances(['destination_migration'])
->willReturn(['destination_migration' => $destination_migration->reveal()]);
$destination_id_map->lookupDestinationId([1])->willReturn(NULL);
$destination_id_map->saveIdMapping(Argument::any(), Argument::any(), MigrateIdMapInterface::STATUS_NEEDS_UPDATE)->willReturn(NULL);
$configuration = [
'no_stub' => FALSE,
......
......@@ -75,8 +75,11 @@ public function testStubWithWeightMapping() {
// We have a term referencing an unmigrated parent, forcing a stub to be
// created.
$term_executable = new MigrateExecutable($this->getMigration('taxonomy_term_stub_test'), $this);
$migration = $this->getMigration('taxonomy_term_stub_test');
$term_executable = new MigrateExecutable($migration, $this);
$term_executable->import();
$this->assertTrue($migration->getIdMap()->getRowBySource(['2']), 'Stub row exists in the ID map table');
// Load the referenced term, which should exist as a stub.
/** @var \Drupal\Core\Entity\ContentEntityBase $stub_entity */
$stub_entity = Term::load(2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment