diff --git a/core/modules/comment/src/Plugin/migrate/source/d7/Comment.php b/core/modules/comment/src/Plugin/migrate/source/d7/Comment.php index e643eb1..1ef4aff 100644 --- a/core/modules/comment/src/Plugin/migrate/source/d7/Comment.php +++ b/core/modules/comment/src/Plugin/migrate/source/d7/Comment.php @@ -31,12 +31,23 @@ public function query() { */ public function prepareRow(Row $row) { $cid = $row->getSourceProperty('cid'); - $node_type = $row->getSourceProperty('node_type'); - $comment_type = 'comment_node_' . $node_type; - $row->setSourceProperty('comment_type', 'comment_node_' . $node_type); - foreach (array_keys($this->getFields('comment', $comment_type)) as $field) { + // Migrate forum and article comments using standard D8 comment types. + switch ($node_type) { + case 'forum': + $comment_type = 'comment_forum'; + break; + case 'article': + $comment_type = 'comment'; + break; + default: + $comment_type = 'comment_node_' . $node_type; + } + $row->setSourceProperty('comment_type', $comment_type); + + $d7_bundle = 'comment_node_' . $node_type; + foreach (array_keys($this->getFields('comment', $d7_bundle)) as $field) { $row->setSourceProperty($field, $this->getFieldValues('comment', $field, $cid)); } diff --git a/core/modules/comment/src/Plugin/migrate/source/d7/CommentType.php b/core/modules/comment/src/Plugin/migrate/source/d7/CommentType.php index 2ac7c97..8b85786 100644 --- a/core/modules/comment/src/Plugin/migrate/source/d7/CommentType.php +++ b/core/modules/comment/src/Plugin/migrate/source/d7/CommentType.php @@ -27,10 +27,15 @@ class CommentType extends DrupalSqlBase { * {@inheritdoc} */ public function query() { - return $this->select('field_config_instance', 'fci') + $query = $this->select('field_config_instance', 'fci') ->distinct() ->fields('fci', ['bundle']) ->condition('fci.entity_type', 'comment'); + + // Forum and article use standard D8 comment types. Exclude these bundles. + $query->condition('fci.bundle', array('comment_node_article', 'comment_node_forum'), 'NOT IN'); + + return $query; } /** diff --git a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php index d06336e..6362b74 100644 --- a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php +++ b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php @@ -30,6 +30,9 @@ public function query() { $query->innerJoin('field_config', 'fc', 'fci.field_id = fc.id'); $query->addField('fc', 'data', 'field_data'); + // Forum and article use standard D8 comment types. Exclude these bundles. + $query->condition('fci.bundle', array('comment_node_article', 'comment_node_forum'), 'NOT IN'); + // Optionally filter by entity type and bundle. if (isset($this->configuration['entity_type'])) { $query->condition('fci.entity_type', $this->configuration['entity_type']); diff --git a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerFormDisplay.php b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerFormDisplay.php index ac599ec..15a7646 100644 --- a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerFormDisplay.php +++ b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerFormDisplay.php @@ -30,6 +30,10 @@ public function query() { 'module', ]); $query->join('field_config', 'fc', 'fci.field_id = fc.id'); + + // Forum and article use standard D8 comment types. Exclude these bundles. + $query->condition('fci.bundle', array('comment_node_article', 'comment_node_forum'), 'NOT IN'); + return $query; } diff --git a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php index 7339e76..3cb7067 100644 --- a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php +++ b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php @@ -46,6 +46,10 @@ public function query() { ->fields('fci', ['entity_type', 'bundle', 'field_name', 'data']) ->fields('fc', ['type']); $query->join('field_config', 'fc', 'fc.field_name = fci.field_name'); + + // Forum and article use standard D8 comment types. Exclude these bundles. + $query->condition('fci.bundle', array('comment_node_article', 'comment_node_forum'), 'NOT IN'); + return $query; }