diff --git a/core/modules/migrate_drupal/tests/fixtures/drupal6.php b/core/modules/migrate_drupal/tests/fixtures/drupal6.php index 3b9efe524eb108eab2be0a9b5ff3dd52439c334e..8f883003afd8e8b23f3070b7bdd76f59ed02025b 100644 --- a/core/modules/migrate_drupal/tests/fixtures/drupal6.php +++ b/core/modules/migrate_drupal/tests/fixtures/drupal6.php @@ -34072,7 +34072,7 @@ 'help' => '', 'relations' => '1', 'hierarchy' => '2', - 'multiple' => '0', + 'multiple' => '1', 'required' => '0', 'tags' => '0', 'module' => 'taxonomy', diff --git a/core/modules/taxonomy/migration_templates/d6_vocabulary_field.yml b/core/modules/taxonomy/migration_templates/d6_vocabulary_field.yml index 5139f318b993cc343390c675ff892d59772b37e9..a1c97356f04d16663f9052fb78acd90be523da77 100644 --- a/core/modules/taxonomy/migration_templates/d6_vocabulary_field.yml +++ b/core/modules/taxonomy/migration_templates/d6_vocabulary_field.yml @@ -8,7 +8,6 @@ source: entity_type: node type: entity_reference target_entity_type: taxonomy_term - cardinality: -1 process: entity_type: 'constants/entity_type' type: 'constants/type' @@ -21,7 +20,7 @@ process: plugin: skip_on_empty method: row 'settings/target_type': 'constants/target_entity_type' - cardinality: 'constants/cardinality' + cardinality: cardinality destination: plugin: md_entity:field_storage_config migration_dependencies: diff --git a/core/modules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php b/core/modules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php index d2d3f19853a16d191de572a4643bf84e1171b6c8..5c605bb4fc3fb2651f5b0eeb7239475f46ffcc60 100644 --- a/core/modules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php +++ b/core/modules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php @@ -9,6 +9,7 @@ use Drupal\migrate\Row; use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase; +use Drupal\Core\Field\FieldStorageDefinitionInterface; /** * Drupal 6 vocabularies source from database. @@ -72,6 +73,7 @@ public function prepareRow(Row $row) { ->execute() ->fetchCol(); $row->setSourceProperty('node_types', $node_types); + $row->setSourceProperty('cardinality', ($row->getSourceProperty('tags') == 1 || $row->getSourceProperty('multiple') == 1) ? FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED : 1); return parent::prepareRow($row); } diff --git a/core/modules/taxonomy/src/Tests/Migrate/d6/MigrateVocabularyFieldInstanceTest.php b/core/modules/taxonomy/src/Tests/Migrate/d6/MigrateVocabularyFieldInstanceTest.php index bab6ae552ad2feae9e9e84dde66ce6087e278110..8f2307da419cc06cb30145974f5e3175b78e8b5b 100644 --- a/core/modules/taxonomy/src/Tests/Migrate/d6/MigrateVocabularyFieldInstanceTest.php +++ b/core/modules/taxonomy/src/Tests/Migrate/d6/MigrateVocabularyFieldInstanceTest.php @@ -10,6 +10,7 @@ use Drupal\field\Entity\FieldConfig; use Drupal\migrate\Entity\Migration; use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase; +use Drupal\taxonomy\Entity\Vocabulary; /** * Vocabulary field instance migration. diff --git a/core/modules/taxonomy/src/Tests/Migrate/d6/MigrateVocabularyFieldTest.php b/core/modules/taxonomy/src/Tests/Migrate/d6/MigrateVocabularyFieldTest.php index 9e866d82eb05e39438da220224a8e84e1b79acab..b8d99ed879f8b08fd87e91e45ebdc98bb265d825 100644 --- a/core/modules/taxonomy/src/Tests/Migrate/d6/MigrateVocabularyFieldTest.php +++ b/core/modules/taxonomy/src/Tests/Migrate/d6/MigrateVocabularyFieldTest.php @@ -37,11 +37,13 @@ protected function setUp() { public function testVocabularyField() { // Test that the field exists. $field_storage_id = 'node.tags'; + /** @var \Drupal\field\FieldStorageConfigInterface $field_storage */ $field_storage = FieldStorageConfig::load($field_storage_id); $this->assertIdentical($field_storage_id, $field_storage->id()); $settings = $field_storage->getSettings(); $this->assertIdentical('taxonomy_term', $settings['target_type'], "Target type is correct."); + $this->assertIdentical(1, $field_storage->getCardinality(), "Field cardinality in 1."); $this->assertIdentical(array('node', 'tags'), Migration::load('d6_vocabulary_field')->getIdMap()->lookupDestinationID(array(4)), "Test IdMap"); } diff --git a/core/modules/taxonomy/tests/src/Unit/Migrate/d6/VocabularyTest.php b/core/modules/taxonomy/tests/src/Unit/Migrate/d6/VocabularyTest.php index 60362d73c89ce449847617f093b2d646e16425d8..ab263d1975bceb87fc5f99ddae008b5e4cac3251 100644 --- a/core/modules/taxonomy/tests/src/Unit/Migrate/d6/VocabularyTest.php +++ b/core/modules/taxonomy/tests/src/Unit/Migrate/d6/VocabularyTest.php @@ -8,6 +8,7 @@ namespace Drupal\Tests\taxonomy\Unit\Migrate\d6; use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase; +use Drupal\Core\Field\FieldStorageDefinitionInterface; /** * Tests D6 vocabulary source plugin. @@ -39,6 +40,7 @@ class VocabularyTest extends MigrateSqlSourceTestCase { 'module' => 'taxonomy', 'weight' => 0, 'node_types' => ['page', 'article'], + 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, ], [ 'vid' => 2, @@ -53,6 +55,7 @@ class VocabularyTest extends MigrateSqlSourceTestCase { 'module' => 'taxonomy', 'weight' => 0, 'node_types' => ['article'], + 'cardinality' => 1, ], ];