summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLee Rowlands2018-01-08 02:06:25 (GMT)
committerLee Rowlands2018-01-08 02:06:25 (GMT)
commit694b95b98af3953fc5a2bfd8e96f0dfdc6e23106 (patch)
treed3a38d2d440b919ec5986e25a7abd2a3abe68112
parentbfe514a0d4746196cb501089dab1563ca1fc6eb9 (diff)
Issue #2575135 by quietone, ckaotik, olegel, mikeryan, larowlan: Dummy map/message tables being created
-rw-r--r--core/modules/migrate/src/Plugin/MigrationDeriverTrait.php3
-rw-r--r--core/modules/migrate/src/Plugin/migrate/id_map/NullIdMap.php223
-rw-r--r--core/modules/migrate_drupal/migrate_drupal.module3
-rw-r--r--core/modules/migrate_drupal/tests/src/Kernel/IdMapTableNoDummyTest.php40
-rw-r--r--core/modules/user/src/Plugin/migrate/ProfileValues.php1
-rw-r--r--core/modules/user/src/Plugin/migrate/User.php1
6 files changed, 271 insertions, 0 deletions
diff --git a/core/modules/migrate/src/Plugin/MigrationDeriverTrait.php b/core/modules/migrate/src/Plugin/MigrationDeriverTrait.php
index 3205c59..54a0494 100644
--- a/core/modules/migrate/src/Plugin/MigrationDeriverTrait.php
+++ b/core/modules/migrate/src/Plugin/MigrationDeriverTrait.php
@@ -25,6 +25,9 @@ trait MigrationDeriverTrait {
'destination' => [
'plugin' => 'null',
],
+ 'idMap' => [
+ 'plugin' => 'null',
+ ],
];
return \Drupal::service('plugin.manager.migration')->createStubMigration($definition)->getSourcePlugin();
}
diff --git a/core/modules/migrate/src/Plugin/migrate/id_map/NullIdMap.php b/core/modules/migrate/src/Plugin/migrate/id_map/NullIdMap.php
new file mode 100644
index 0000000..a44c838
--- /dev/null
+++ b/core/modules/migrate/src/Plugin/migrate/id_map/NullIdMap.php
@@ -0,0 +1,223 @@
+<?php
+
+namespace Drupal\migrate\Plugin\migrate\id_map;
+
+use Drupal\Core\Plugin\PluginBase;
+use Drupal\migrate\MigrateMessageInterface;
+use Drupal\migrate\Plugin\MigrateIdMapInterface;
+use Drupal\migrate\Plugin\MigrationInterface;
+use Drupal\migrate\Row;
+
+/**
+ * Defines the null ID map implementation.
+ *
+ * This serves as a dummy in order to not store anything.
+ *
+ * @PluginID("null")
+ */
+class NullIdMap extends PluginBase implements MigrateIdMapInterface {
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setMessage(MigrateMessageInterface $message) {
+ // Do nothing.
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getRowBySource(array $source_id_values) {
+ return [];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getRowByDestination(array $destination_id_values) {
+ return [];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getRowsNeedingUpdate($count) {
+ return 0;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function lookupSourceID(array $destination_id_values) {
+ return [];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function lookupDestinationId(array $source_id_values) {
+ return [];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function lookupDestinationIds(array $source_id_values) {
+ return [];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function saveIdMapping(Row $row, array $destination_id_values, $source_row_status = MigrateIdMapInterface::STATUS_IMPORTED, $rollback_action = MigrateIdMapInterface::ROLLBACK_DELETE) {
+ // Do nothing.
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function saveMessage(array $source_id_values, $message, $level = MigrationInterface::MESSAGE_ERROR) {
+ // Do nothing.
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getMessageIterator(array $source_id_values = [], $level = NULL) {
+ return new \ArrayIterator([]);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function prepareUpdate() {
+ // Do nothing.
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function processedCount() {
+ return 0;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function importedCount() {
+ return 0;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function updateCount() {
+ return 0;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function errorCount() {
+ return 0;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function messageCount() {
+ return 0;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function delete(array $source_id_values, $messages_only = FALSE) {
+ // Do nothing.
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function deleteDestination(array $destination_id_values) {
+ // Do nothing.
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setUpdate(array $source_id_values) {
+ // Do nothing.
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function clearMessages() {
+ // Do nothing.
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function destroy() {
+ // Do nothing.
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function currentDestination() {
+ return NULL;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function currentSource() {
+ return NULL;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getQualifiedMapTableName() {
+ return '';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function rewind() {
+ return NULL;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function current() {
+ return NULL;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function key() {
+ return '';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function next() {
+ return NULL;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function valid() {
+ return FALSE;
+ }
+
+}
diff --git a/core/modules/migrate_drupal/migrate_drupal.module b/core/modules/migrate_drupal/migrate_drupal.module
index 9f623ea..b32fb58 100644
--- a/core/modules/migrate_drupal/migrate_drupal.module
+++ b/core/modules/migrate_drupal/migrate_drupal.module
@@ -40,6 +40,9 @@ function migrate_drupal_migration_plugins_alter(&$definitions) {
'destination' => [
'plugin' => 'null',
],
+ 'idMap' => [
+ 'plugin' => 'null',
+ ],
];
$vocabulary_migration = \Drupal::service('plugin.manager.migration')->createStubMigration($vocabulary_migration_definition);
diff --git a/core/modules/migrate_drupal/tests/src/Kernel/IdMapTableNoDummyTest.php b/core/modules/migrate_drupal/tests/src/Kernel/IdMapTableNoDummyTest.php
new file mode 100644
index 0000000..02e98b7
--- /dev/null
+++ b/core/modules/migrate_drupal/tests/src/Kernel/IdMapTableNoDummyTest.php
@@ -0,0 +1,40 @@
+<?php
+
+namespace Drupal\Tests\migrate_drupal\Kernel;
+
+use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
+
+/**
+ * Test that no dummy migrate_map tables are created.
+ *
+ * @group migrate_drupal
+ */
+class IdMapTableNoDummyTest extends MigrateDrupal6TestBase {
+
+ /**
+ * The migration plugin manager.
+ *
+ * @var \Drupal\migrate\Plugin\MigrationPluginManagerInterface
+ */
+ protected $pluginManager;
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setUp() {
+ parent::setUp();
+ $this->pluginManager = $this->container->get('plugin.manager.migration');
+ $this->pluginManager->createInstance('d6_user');
+ }
+
+ /**
+ * Test that dummy map tables do not exist.
+ */
+ public function testNoDummyTables() {
+ $database = \Drupal::database();
+ $tables = $database->schema()->findTables('%migrate_map%');
+ $dummy_tables = preg_grep("/.*migrate_map_([0-9a-fA-F]){13}/", $tables);
+ $this->assertCount(0, $dummy_tables);
+ }
+
+}
diff --git a/core/modules/user/src/Plugin/migrate/ProfileValues.php b/core/modules/user/src/Plugin/migrate/ProfileValues.php
index 9e02521..b082d59 100644
--- a/core/modules/user/src/Plugin/migrate/ProfileValues.php
+++ b/core/modules/user/src/Plugin/migrate/ProfileValues.php
@@ -28,6 +28,7 @@ class ProfileValues extends Migration {
'ignore_map' => TRUE,
] + $this->source;
$definition['destination']['plugin'] = 'null';
+ $definition['idMap']['plugin'] = 'null';
try {
$profile_field_migration = $this->migrationPluginManager->createStubMigration($definition);
$source_plugin = $profile_field_migration->getSourcePlugin();
diff --git a/core/modules/user/src/Plugin/migrate/User.php b/core/modules/user/src/Plugin/migrate/User.php
index 0605443..5316259 100644
--- a/core/modules/user/src/Plugin/migrate/User.php
+++ b/core/modules/user/src/Plugin/migrate/User.php
@@ -21,6 +21,7 @@ class User extends FieldMigration {
'ignore_map' => TRUE,
] + $this->source;
$definition['destination']['plugin'] = 'null';
+ $definition['idMap']['plugin'] = 'null';
if (\Drupal::moduleHandler()->moduleExists('field')) {
$definition['source']['plugin'] = 'd7_field_instance';
$field_migration = $this->migrationPluginManager->createStubMigration($definition);