diff --git a/core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateForumTest.php b/core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateForumTest.php index 0d3c447..454f58c 100644 --- a/core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateForumTest.php +++ b/core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateForumTest.php @@ -50,7 +50,7 @@ protected function setUp() { */ public function testForumMigration() { $node = Node::load(19); - $this->assertEquals([0 => ['target_id' => '7']], $node->get('taxonomy_forums')->getValue()); + $this->assertEquals(8, $node->taxonomy_forums->target_id); } } diff --git a/core/modules/migrate_drupal/migrate_drupal.module b/core/modules/migrate_drupal/migrate_drupal.module index 22ed76b..10aa72b 100644 --- a/core/modules/migrate_drupal/migrate_drupal.module +++ b/core/modules/migrate_drupal/migrate_drupal.module @@ -57,6 +57,12 @@ function migrate_drupal_migration_plugins_alter(&$definitions) { $plugin_ids = ['d6_term_node:' . $source_vid, 'd6_term_node_revision:' . $source_vid]; foreach ($plugin_ids as $plugin_id) { if (isset($definitions[$plugin_id])) { + // The Forum module is expecting 'taxonomy_forums' as the field name + // for the forum nodes. The 'forum_vocabulary' source property is + // evaluated in Drupal\taxonomy\Plugin\migrate\source\d6\Vocabulary + // and is set to true if the vocabulary vid being migrated is the + // same as the one in the 'forum_nav_vocabulary' variable on the + // source site. $destination_vid = $row->getSourceProperty('forum_vocabulary') ? 'taxonomy_forums' : $row->getDestinationProperty('vid'); $definitions[$plugin_id]['process'][$destination_vid] = 'tid'; } diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php index 8dea7d0..1bc5aa8 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php @@ -44,7 +44,7 @@ protected function getEntityCounts() { 'contact_form' => 5, 'configurable_language' => 5, 'editor' => 2, - 'field_config' => 73, + 'field_config' => 72, 'field_storage_config' => 48, 'file' => 7, 'filter_format' => 7, @@ -59,7 +59,7 @@ protected function getEntityCounts() { 'shortcut_set' => 1, 'action' => 22, 'menu' => 8, - 'taxonomy_term' => 7, + 'taxonomy_term' => 8, 'taxonomy_vocabulary' => 6, 'tour' => 4, 'user' => 7, diff --git a/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_display.yml b/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_display.yml index 22e5004..53d7dc4 100644 --- a/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_display.yml +++ b/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_display.yml @@ -29,6 +29,9 @@ process: migration: d6_taxonomy_vocabulary source: vid - + # This plugin checks if the vocabulary being migrated is the one used for + # forums. If it is, the field name is set to 'taxonomy_forums' as it is + # what the Forum module is expecting. Otherwise, it is left unchanged. plugin: forum_vocabulary destination: plugin: component_entity_display diff --git a/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_form_display.yml b/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_form_display.yml index 8b70e4b..2cf20cd 100644 --- a/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_form_display.yml +++ b/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_form_display.yml @@ -33,6 +33,9 @@ process: migration: d6_taxonomy_vocabulary source: vid - + # This plugin checks if the vocabulary being migrated is the one used for + # forums. If it is, the field name is set to 'taxonomy_forums' as it is + # what the Forum module is expecting. Otherwise, it is left unchanged. plugin: forum_vocabulary destination: plugin: component_entity_form_display diff --git a/core/modules/taxonomy/migration_templates/d6_vocabulary_field.yml b/core/modules/taxonomy/migration_templates/d6_vocabulary_field.yml index 08b86f2..fb96fa3 100644 --- a/core/modules/taxonomy/migration_templates/d6_vocabulary_field.yml +++ b/core/modules/taxonomy/migration_templates/d6_vocabulary_field.yml @@ -17,6 +17,9 @@ process: migration: d6_taxonomy_vocabulary source: vid - + # This plugin checks if the vocabulary being migrated is the one used for + # forums. If it is, the field name is set to 'taxonomy_forums' as it is + # what the Forum module is expecting. Otherwise, it is left unchanged. plugin: forum_vocabulary - plugin: skip_on_empty diff --git a/core/modules/taxonomy/migration_templates/d6_vocabulary_field_instance.yml b/core/modules/taxonomy/migration_templates/d6_vocabulary_field_instance.yml index bb896c1..2e4f3a2 100644 --- a/core/modules/taxonomy/migration_templates/d6_vocabulary_field_instance.yml +++ b/core/modules/taxonomy/migration_templates/d6_vocabulary_field_instance.yml @@ -24,6 +24,9 @@ process: migration: d6_taxonomy_vocabulary source: vid - + # This plugin checks if the vocabulary being migrated is the one used for + # forums. If it is, the field name is set to 'taxonomy_forums' as it is + # what the Forum module is expecting. Otherwise, it is left unchanged. plugin: forum_vocabulary - plugin: skip_on_empty diff --git a/core/modules/taxonomy/src/Plugin/migrate/process/ForumVocabulary.php b/core/modules/taxonomy/src/Plugin/migrate/process/ForumVocabulary.php index db99652..be4b9cc 100644 --- a/core/modules/taxonomy/src/Plugin/migrate/process/ForumVocabulary.php +++ b/core/modules/taxonomy/src/Plugin/migrate/process/ForumVocabulary.php @@ -7,6 +7,14 @@ use Drupal\migrate\Row; /** + * Checks if the vocabulary being migrated is the one used for forums. + * + * The forum module is expecting 'taxonomy_forums' as the field name for the + * forum nodes. The 'forum_vocabulary' source property is evaluated in + * Drupal\taxonomy\Plugin\migrate\source\d6\Vocabulary and is set to true if + * the vocabulary vid being migrated is the same as the one in the + * 'forum_nav_vocabulary' variable on the source site. + * * @MigrateProcessPlugin( * id = "forum_vocabulary" * ) 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 0a64ef9..8924c33 100644 --- a/core/modules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php +++ b/core/modules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php @@ -69,9 +69,14 @@ public function prepareRow(Row $row) { ->fetchCol(); $row->setSourceProperty('node_types', $node_types); $row->setSourceProperty('cardinality', ($row->getSourceProperty('tags') == 1 || $row->getSourceProperty('multiple') == 1) ? FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED : 1); + + // If the vid of the vocabulary being migrated is equal to the vid in the + // 'forum_nav_vocabulary' variable, set the 'forum_vocabulary' source + // property to true so we can know this is the vocabulary used for forums. if ($this->variableGet('forum_nav_vocabulary', 0) == $row->getSourceProperty('vid')) { $row->setSourceProperty('forum_vocabulary', TRUE); } + return parent::prepareRow($row); }