summaryrefslogtreecommitdiffstats
path: root/core/modules/migrate_drupal
diff options
context:
space:
mode:
authorAlex Pott2018-07-16 10:19:07 (GMT)
committerAlex Pott2018-07-16 10:19:15 (GMT)
commit8455641d37c02ef06a4bdc88f4f206146cbb9eac (patch)
tree8c5f0ff22c23ac6db60d4026bac34bb430b97d53 /core/modules/migrate_drupal
parent9f4ca29c06fc9138243c25f238a6b34aee8b6059 (diff)
Issue #2981225 by maxocub, RumyanaRuseva, mpp: Migration fails to create instance when non-bundleable entity type exists
(cherry picked from commit 68c7b00cc58fed916f2a35a8aee94e3e9a94e91f)
Diffstat (limited to 'core/modules/migrate_drupal')
-rw-r--r--core/modules/migrate_drupal/src/Plugin/migrate/EntityReferenceTranslationDeriver.php10
-rw-r--r--core/modules/migrate_drupal/tests/fixtures/drupal7.php9
2 files changed, 16 insertions, 3 deletions
diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/EntityReferenceTranslationDeriver.php b/core/modules/migrate_drupal/src/Plugin/migrate/EntityReferenceTranslationDeriver.php
index d81b92c..bc33695 100644
--- a/core/modules/migrate_drupal/src/Plugin/migrate/EntityReferenceTranslationDeriver.php
+++ b/core/modules/migrate_drupal/src/Plugin/migrate/EntityReferenceTranslationDeriver.php
@@ -109,6 +109,7 @@ class EntityReferenceTranslationDeriver extends DeriverBase implements Container
$derivative_key = $entity_type . '__' . $bundle;
$derivative = $base_plugin_definition;
+ $entity_type_definition = $this->entityTypeManager->getDefinition($entity_type);
// Set the migration label.
$derivative['label'] = $this->t('@label (@derivative)', [
@@ -118,10 +119,11 @@ class EntityReferenceTranslationDeriver extends DeriverBase implements Container
// Set the source plugin.
$derivative['source']['plugin'] = 'content_entity' . PluginBase::DERIVATIVE_SEPARATOR . $entity_type;
- $derivative['source']['bundle'] = $bundle;
+ if ($entity_type_definition->hasKey('bundle')) {
+ $derivative['source']['bundle'] = $bundle;
+ }
// Set the process pipeline.
- $entity_type_definition = $this->entityTypeManager->getDefinition($entity_type);
$id_key = $entity_type_definition->getKey('id');
$derivative['process'][$id_key] = $id_key;
if ($entity_type_definition->isRevisionable()) {
@@ -135,7 +137,9 @@ class EntityReferenceTranslationDeriver extends DeriverBase implements Container
// Set the destination plugin.
$derivative['destination']['plugin'] = 'entity' . PluginBase::DERIVATIVE_SEPARATOR . $entity_type;
- $derivative['destination']['default_bundle'] = $bundle;
+ if ($entity_type_definition->hasKey('bundle')) {
+ $derivative['destination']['default_bundle'] = $bundle;
+ }
if ($entity_type_definition->isTranslatable()) {
$derivative['destination']['translations'] = TRUE;
}
diff --git a/core/modules/migrate_drupal/tests/fixtures/drupal7.php b/core/modules/migrate_drupal/tests/fixtures/drupal7.php
index 3bd7e70..5311407 100644
--- a/core/modules/migrate_drupal/tests/fixtures/drupal7.php
+++ b/core/modules/migrate_drupal/tests/fixtures/drupal7.php
@@ -4492,6 +4492,15 @@ $connection->insert('field_config_instance')
'data' => 'a:6:{s:5:"label";s:11:"Reference 2";s:6:"widget";a:4:{s:4:"type";s:14:"options_select";s:6:"weight";s:2:"21";s:8:"settings";a:0:{}s:6:"module";s:7:"options";}s:8:"settings";a:1:{s:18:"user_register_form";b:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:21:"entityreference_label";s:8:"settings";a:2:{s:4:"link";b:0;s:13:"bypass_access";b:0;}s:6:"module";s:15:"entityreference";s:6:"weight";i:21;}}s:8:"required";b:0;s:11:"description";s:0:"";}',
'deleted' => '0',
))
+->values(array(
+ 'id' => '66',
+ 'field_id' => '38',
+ 'field_name' => 'field_reference',
+ 'entity_type' => 'user',
+ 'bundle' => 'user',
+ 'data' => 'a:7:{s:5:"label";s:9:"Reference";s:6:"widget";a:5:{s:6:"weight";s:2:"11";s:4:"type";s:14:"options_select";s:6:"module";s:7:"options";s:6:"active";i:1;s:8:"settings";a:0:{}}s:8:"settings";a:2:{s:18:"user_register_form";i:0;s:23:"entity_translation_sync";b:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:21:"entityreference_label";s:8:"settings";a:2:{s:4:"link";b:0;s:13:"bypass_access";b:0;}s:6:"module";s:15:"entityreference";s:6:"weight";i:9;}}s:8:"required";i:0;s:11:"description";s:0:"";s:13:"default_value";N;}',
+ 'deleted' => '0',
+))
->execute();
$connection->schema()->createTable('field_data_body', array(