Issue #2682705 by davidwbarratt, alexpott, vprocessor, miiimooo, milesw: Migrate process plugin does not save stubs to the idmap, leads to duplicates and broken references

8.2.x
Nathaniel Catchpole 2016-03-19 12:35:51 +09:00
parent f5f647995b
commit 56507636a6
3 changed files with 11 additions and 2 deletions

View File

@ -11,6 +11,7 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
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 @@ class Migration extends ProcessPluginBase implements ContainerFactoryPluginInter
$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) {

View File

@ -67,6 +67,7 @@ class MigrationTest extends MigrateProcessTestCase {
$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,

View File

@ -75,8 +75,11 @@ class MigrateTaxonomyTermStubTest extends MigrateDrupalTestBase {
// 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);