diff -u b/core/modules/node/migration_templates/d6_node_translation.yml b/core/modules/node/migration_templates/d6_node.yml --- b/core/modules/node/migration_templates/d6_node_translation.yml +++ b/core/modules/node/migration_templates/d6_node.yml @@ -1,14 +1,16 @@ -id: d6_node_translation -label: Node translations +id: d6_node +label: Nodes migration_tags: - Drupal 6 deriver: Drupal\node\Plugin\migrate\D6NodeDeriver source: plugin: d6_node - translations: true process: + # In D6, nodes always have a tnid, but it's zero for untranslated nodes. + # We normalize it to equal the nid in that case. + # @see \Drupal\node\Plugin\migrate\source\d6\Node::prepareRow(). nid: tnid - type: type + vid: vid langcode: plugin: default_value source: language @@ -31,20 +33,19 @@ revision_timestamp: timestamp # unmapped d6 fields. +# tnid # translate # moderate # comment destination: plugin: entity:node - translations: true migration_dependencies: required: - d6_user - d6_node_type - d6_node_settings - d6_filter_format - - language optional: - d6_field_instance_widget_settings - d6_field_formatter_settings diff -u b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php --- b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php +++ b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php @@ -84,8 +84,13 @@ $this->assertIdentical('Drupal Groups', $node->field_test_link->title); $this->assertIdentical([], $node->field_test_link->options['attributes']); + // Rerun migration with invalid link attributes and a different URL and + // title. If only the attributes are changed the error does not occur. + Database::getConnection('default', 'migrate') + $this->assertSame('Buy it now', $node->field_test_link->title); + $this->assertSame(['attributes' => ['target' => '_blank']], $node->field_test_link->options); + // Test that translations are working. - $node = Node::load(9); $this->assertIdentical('en', $node->langcode->value); $this->assertIdentical('The Real McCoy', $node->title->value); $this->assertTrue($node->hasTranslation('fr'), "Node 9 has french translation"); @@ -93,12 +98,6 @@ // Node 10 is a translation of node 9, and should not be imported separately. $this->assertNull(Node::load(10), "Node 10 doesn't exist in D8, it was a translation"); - // Rerun migration with invalid link attributes and a different URL and - // title. If only the attributes are changed the error does not occur. - Database::getConnection('default', 'migrate') - $this->assertSame('Buy it now', $node->field_test_link->title); - $this->assertSame(['attributes' => ['target' => '_blank']], $node->field_test_link->options); - // Rerun migration with two source database changes. // 1. Add an invalid link attributes and a different URL and // title. If only the attributes are changed the error does not occur. only in patch2: unchanged: --- /dev/null +++ b/core/modules/node/migration_templates/d6_node_translation.yml @@ -0,0 +1,51 @@ +id: d6_node_translation +label: Node translations +migration_tags: + - Drupal 6 +deriver: Drupal\node\Plugin\migrate\D6NodeDeriver +source: + plugin: d6_node + translations: true +process: + nid: tnid + type: type + langcode: + plugin: default_value + source: language + default_value: "und" + title: title + uid: node_uid + status: status + created: created + changed: changed + promote: promote + sticky: sticky + 'body/format': + plugin: migration + migration: d6_filter_format + source: format + 'body/value': body + 'body/summary': teaser + revision_uid: revision_uid + revision_log: log + revision_timestamp: timestamp + +# unmapped d6 fields. +# translate +# moderate +# comment + +destination: + plugin: entity:node + translations: true +migration_dependencies: + required: + - d6_user + - d6_node_type + - d6_node_settings + - d6_filter_format + - language + optional: + - d6_field_instance_widget_settings + - d6_field_formatter_settings + - d6_upload_field_instance