diff -u b/core/modules/content_translation/migration_templates/d6_custom_block_translation.yml b/core/modules/content_translation/migration_templates/d6_custom_block_translation.yml --- b/core/modules/content_translation/migration_templates/d6_custom_block_translation.yml +++ b/core/modules/content_translation/migration_templates/d6_custom_block_translation.yml @@ -7,25 +7,27 @@ constants: type: basic process: - id: bid + id: + plugin: migration + migration: d6_custom_block + source: + - bid langcode: language type: 'constants/type' - info: info - title: + info: plugin: i18n_translation source: - title_untranslated - title_translated - description: + 'body/value': plugin: i18n_translation source: - - description_untranslated - - description_translated + - body_untranslated + - body_translated 'body/format': plugin: migration migration: d6_filter_format source: format - 'body/value': body destination: plugin: entity:block_content no_stub: true diff -u b/core/modules/content_translation/src/Plugin/migrate/source/d6/BoxTranslation.php b/core/modules/content_translation/src/Plugin/migrate/source/d6/BoxTranslation.php --- b/core/modules/content_translation/src/Plugin/migrate/source/d6/BoxTranslation.php +++ b/core/modules/content_translation/src/Plugin/migrate/source/d6/BoxTranslation.php @@ -24,19 +24,17 @@ // method prepareRow() is then used to obtain the translation for the other // property. $query = $this->select('boxes', 'b') - ->fields('b', ['bid', 'body', 'info', 'format']); + ->fields('b', ['bid', 'body', 'info', 'format']) + ->fields('i18n', ['lid', 'property']) + ->fields('lt', ['lid', 'translation', 'language']); $query->orderBy('b.bid'); - // Add in the property, which is either title or description. - $query->leftJoin('i18n_strings', 'i18n', 'b.bid = i18n.objectid'); + // Add in the property, which is either title or body. + $query->leftJoin('i18n_strings', 'i18n', 'i18n.objectid = b.bid'); $query->isNotNull('i18n.lid'); - $query->addField('i18n', 'lid'); - $query->addField('i18n', 'property'); // Add in the translation for the property. - $query->leftJoin('locales_target', 'lt', 'i18n.lid = lt.lid'); - $query->addField('lt', 'language'); - $query->addField('lt', 'translation'); + $query->leftJoin('locales_target', 'lt', 'lt.lid = i18n.lid'); return $query; } @@ -54,16 +52,15 @@ $row->setSourceProperty('migrate', TRUE); } // Set untranslated values as defaults. - $row->setSourceProperty('title_untranslated', $row->getSourceProperty('link_title')); - $row->setSourceProperty('options', unserialize($row->getSourceProperty('options'))); - $row->setSourceProperty('description_untranslated', Unicode::truncate($row->getSourceProperty('options/attributes/title'), 255)); + $row->setSourceProperty('title_untranslated', $row->getSourceProperty('info')); + $row->setSourceProperty('body_untranslated', Unicode::truncate($row->getSourceProperty('options/attributes/title'), 255)); // Save the translation for this property. $property = $row->getSourceProperty('property'); $row->setSourceProperty($property . '_translated', $row->getSourceProperty('translation')); // Get the translation for the property not already in the row. - $property2 = ($property == 'title') ? 'description' : 'title'; + $property2 = ($property == 'title') ? 'body' : 'title'; $query = $this->select('i18n_strings', 'i18n') ->fields('i18n', ['lid']); $query @@ -83,8 +80,8 @@ return [ 'bid' => $this->t('The block numeric identifier.'), 'language' => $this->t('Language for this field.'), - 'title' => $this->t('Menu link title translation.'), - 'description' => $this->t('Menu link description translation.'), + 'title' => $this->t('Block title translation.'), + 'body' => $this->t('Block body translation.'), ]; } diff -u b/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateCustomBlockContentTranslationTest.php b/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateCustomBlockContentTranslationTest.php --- b/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateCustomBlockContentTranslationTest.php +++ b/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateCustomBlockContentTranslationTest.php @@ -49,8 +49,6 @@ */ public function testCustomBlockContentTranslation() { /** @var BlockContent $block */ - $block = BlockContent::load(1); - $block = BlockContent::load(1)->getTranslation('fr'); $this->assertSame('fr - Static Block', $block->label()); $this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time()); diff -u b/core/modules/content_translation/tests/src/Kernel/Plugin/migrate/source/d6/BoxTranslationTest.php b/core/modules/content_translation/tests/src/Kernel/Plugin/migrate/source/d6/BoxTranslationTest.php --- b/core/modules/content_translation/tests/src/Kernel/Plugin/migrate/source/d6/BoxTranslationTest.php +++ b/core/modules/content_translation/tests/src/Kernel/Plugin/migrate/source/d6/BoxTranslationTest.php @@ -46,7 +46,7 @@ 'objectid' => 1, 'type' => 'block', 'property' => 'title', - 'objectindex' => 0, + 'objectindex' => 1, 'format' => 0, ], [ @@ -54,7 +54,7 @@ 'objectid' => 1, 'type' => 'block', 'property' => 'body', - 'objectindex' => 0, + 'objectindex' => 1, 'format' => 0, ], [ @@ -62,7 +62,7 @@ 'objectid' => 2, 'type' => 'block', 'property' => 'body', - 'objectindex' => 0, + 'objectindex' => 2, 'format' => 2, ], ]; @@ -85,7 +85,7 @@ 'i18n_status' => 0, ], [ - 'lid' => 2, + 'lid' => 3, 'language' => 'zu', 'translation' => 'zu - body translation', 'plid' => 0, @@ -97,41 +97,32 @@ // The expected results. $tests[0]['expected_results'] = [ [ - 'lid' => '2', - 'type' => 'block', - 'property' => 'body', - 'objectid' => '1', - 'lt_lid' => '2', + 'lid' => '1', + 'property' => 'title', 'language' => 'fr', - 'translation' => 'fr - body translation', + 'translation' => 'fr - info translation', 'bid' => '1', - 'body' => 'fr - body translation', - 'info' => 'fr - info translation', + 'body' => 'box 1 body', + 'info' => 'box 1 info', 'format' => '2', ], [ 'lid' => '2', - 'type' => 'block', 'property' => 'body', - 'objectid' => '1', - 'lt_lid' => '2', - 'language' => 'zu', - 'translation' => 'zu - body translation', + 'language' => 'fr', + 'translation' => 'fr - body translation', 'bid' => '1', - 'body' => 'zu - body translation', + 'body' => 'box 1 body', 'info' => 'box 1 info', 'format' => '2', ], [ 'lid' => '3', - 'type' => 'block', 'property' => 'body', - 'objectid' => '2', - 'lt_lid' => NULL, - 'language' => NULL, - 'translation' => NULL, + 'language' => 'zu', + 'translation' => 'zu - body translation', 'bid' => '2', - 'body' => NULL, + 'body' => 'box 2 body', 'info' => 'box 2 info', 'format' => '2', ], diff -u b/core/modules/migrate_drupal/tests/fixtures/drupal6.php b/core/modules/migrate_drupal/tests/fixtures/drupal6.php --- b/core/modules/migrate_drupal/tests/fixtures/drupal6.php +++ b/core/modules/migrate_drupal/tests/fixtures/drupal6.php @@ -731,7 +731,7 @@ 'throttle' => '0', 'visibility' => '0', 'pages' => '', - 'title' => 'zu - Test Title 02', + 'title' => '', 'cache' => '-1', )) ->values(array( @@ -746,7 +746,7 @@ 'throttle' => '0', 'visibility' => '0', 'pages' => '', - 'title' => '', + 'title' => 'zu - Test Title 02', 'cache' => '-1', )) ->values(array( @@ -8414,23 +8414,6 @@ 'mysql_character_set' => 'utf8', )); -$connection->insert('i18n_blocks') -->fields(array( - 'ibid', - 'module', - 'delta', - 'type', - 'language', -)) -->values(array( - 'ibid' => '1', - 'module' => 'user', - 'delta' => '1', - 'type' => '0', - 'language' => 'zu', -)) -->execute(); - $connection->schema()->createTable('i18n_strings', array( 'fields' => array( 'lid' => array( @@ -8481,6 +8464,23 @@ 'mysql_character_set' => 'utf8', )); +$connection->insert('i18n_blocks') +->fields(array( + 'ibid', + 'module', + 'delta', + 'type', + 'language', +)) +->values(array( + 'ibid' => '1', + 'module' => 'user', + 'delta' => '1', + 'type' => '0', + 'language' => 'zu', +)) +->execute(); + $connection->schema()->createTable('i18n_strings', array( 'fields' => array( 'lid' => array(