Problem/Motivation

A migration for block translated strings is needed. The block translated strings are in the block table and the language code in the i18n_blocks table.

Proposed resolution

Write a custom source plugin, refer to the existing block source plugin.
Write block translation migrations based on the existing block migrations.
And, of course, tests.

CommentFileSizeAuthor
#239 interdiff.txt2.08 KBquietone
#239 2225681-239.patch11.89 KBquietone
#234 2225681-233.patch11.61 KBquietone
#234 interdiff.txt2.58 KBquietone
#225 2225681-225.patch11.08 KBquietone
#225 interdiff.txt640 bytesquietone
#223 interdiff.txt1.97 KBquietone
#223 2225681-223.patch11.1 KBquietone
#217 2225681-217.patch11.23 KBjofitz
#217 interdiff-215-217.txt636 bytesjofitz
#215 2225681-215.patch11.34 KBquietone
#215 interdiff.txt1.13 KBquietone
#213 2225681-213.patch11.29 KBquietone
#209 interdiff.txt2.43 KBquietone
#209 2225681-209.patch11.27 KBquietone
#207 2225681-207.patch13.1 KBquietone
#207 interdiff.txt898 bytesquietone
#205 interdiff-204-205.txt7.79 KBquietone
#205 interdiff-fail.patch776 bytesquietone
#205 2225681-205-fail.patch12.59 KBquietone
#205 2225681-205.patch12.6 KBquietone
#204 interdiff.txt898 bytesquietone
#204 2225681-204.patch18.1 KBquietone
#201 interdiff-198-201.txt1.03 KBquietone
#201 interdiff-fail.txt776 bytesquietone
#201 2225681-201-fail.patch17.6 KBquietone
#201 2225681-201.patch17.6 KBquietone
#198 2225681-198.patch18.26 KBquietone
#196 2225681-196.patch18.52 KBquietone
#194 2225681-194.patch18.04 KByogeshmpawar
#185 interdiff.txt1.92 KBquietone
#185 2225681-185.patch18.19 KBquietone
#183 interdiff.txt525 bytesquietone
#183 2225681-183.patch18.19 KBquietone
#181 interdiff.txt506 bytesquietone
#181 2225681-181.patch18.18 KBquietone
#179 2225681-179.patch18.12 KBjofitz
#179 interdiff-176-179.txt2.55 KBjofitz
#176 interdiff.txt8.7 KBquietone
#176 2225681-176.patch16.83 KBquietone
#176 2225681-fail-176.patch16.83 KBquietone
#174 interdiff.txt623 bytesquietone
#174 2225681-174.patch10.29 KBquietone
#172 interdiff.txt968 bytesquietone
#172 2225681-172.patch9.48 KBquietone
#165 interdiff.txt583 bytesquietone
#165 2225681-165.patch9.46 KBquietone
#163 interdiff-2225681-161-163.txt333 bytesRytoEX
#163 interdiff-2225681-146-163.txt353 bytesRytoEX
#163 2225681-163.patch8.72 KBRytoEX
#161 interdiff-2225681-146-161.txt351 bytesRytoEX
#161 2225681-161.patch8.71 KBRytoEX
#146 interdiff-143-146.txt1.35 KBjofitz
#146 interdiff-139-146.txt915 bytesjofitz
#146 2225681-146.patch8.71 KBjofitz
#143 interdiff-139-143.txt2.32 KBjofitz
#143 2225681-143.patch8.71 KBjofitz
#139 interdiff.txt1.27 KBquietone
#139 2225681-139.patch8.73 KBquietone
#139 interdiff.txt2.93 KBquietone
#139 2225681-138.patch8.73 KBquietone
#136 interdiff-131-136.txt12.42 KBjofitz
#136 2225681-136.patch8.39 KBjofitz
#131 interdiff-124-129.txt758 bytesdipakmdhrm
#131 2225681-129.patch8.69 KBdipakmdhrm
#128 interdiff-124-128.diff758 bytesdipakmdhrm
#128 2225681-128.patch16.39 KBdipakmdhrm
#124 interdiff-119-124.txt4.21 KBjofitz
#124 2225681-124.patch8.69 KBjofitz
#119 interdiff-2225681-114-119.txt1.04 KBdipakmdhrm
#119 2225681-119.patch9.88 KBdipakmdhrm
#114 2225681-114.patch9.89 KBjofitz
#114 interdiff-110-114.txt1.25 KBjofitz
#110 2225681-110.patch10.16 KBjofitz
#108 2225681-108.patch10.16 KBjofitz
#106 2225681-106.patch10.34 KBjofitz
#106 interdiff-104-106.txt16.04 KBjofitz
#104 2225681-104.patch10.45 KBmaxocub
#103 interdiff-101-103.txt1.32 KBjofitz
#103 2225681-103.patch22.41 KBjofitz
#101 interdiff.txt1.13 KBquietone
#101 2225681-101.patch22.53 KBquietone
#99 interdiff.txt1.88 KBquietone
#99 2225681-99.patch22.5 KBquietone
#86 interdiff-83-86.txt789 bytesjofitz
#86 2225681-86.patch23.51 KBjofitz
#83 interdiff.txt8.93 KBquietone
#83 migrate_d6_i18n_blocks-2225681-83.patch23.55 KBquietone
#81 interdiff.txt12.7 KBquietone
#81 migrate_d6_i18n_blocks-2225681-81.patch24.01 KBquietone
#72 interdiff.txt810 bytesquietone
#72 migrate_d6_i18n_blocks-2225681-72.patch22.07 KBquietone
#70 interdiff.txt35.06 KBquietone
#70 migrate_d6_i18n_blocks-2225681-70.patch22.05 KBquietone
#65 interdiff.txt1.37 KBquietone
#65 migrate_d6_i18n_blocks-2225681-65.patch21.77 KBquietone
#63 interdiff.txt1023 bytesquietone
#63 migrate_d6_i18n_blocks-2225681-63.patch21.13 KBquietone
#61 interdiff.txt37.5 KBquietone
#61 migrate_d6_i18n_blocks-2225681-61.patch21.12 KBquietone
#59 interdiff.txt1.26 KBquietone
#59 migrate_d6_i18n_blocks-2225681-59.patch38.38 KBquietone
#57 interdiff.txt4.64 KBquietone
#57 migrate_d6_i18n_blocks-2225681-57.patch38.38 KBquietone
#54 migrate_d6_i18n_blocks-2225681-54.patch38.55 KBquietone
#49 interdiff.txt18.23 KBquietone
#49 migrate_d6_i18n_blocks-2225681-49.patch45.26 KBquietone
#47 interdiff.txt2.38 KBquietone
#47 migrate_d6_i18n_blocks-2225681-47.patch44.84 KBquietone
#43 migrate_d6_i18n_blocks-2225681-40.patch46.36 KBAda Hernandez
#39 migrate_d6_i18n_blocks-2225681-39.patch46.36 KBAda Hernandez
#39 interdiff.txt7.73 KBAda Hernandez
#35 2225681-35.patch44.52 KBjofitz
#35 interdiff.txt717 bytesjofitz
#33 2225681-33.patch43.82 KBjofitz
#33 interdiff.txt714 bytesjofitz
#29 2225681-29.patch49.41 KBjofitz
#29 interdiff.txt714 bytesjofitz
#27 2225681-27.patch43.53 KBjofitz
#27 interdiff.txt1.19 KBjofitz
#25 2225681-25.patch42.85 KBjofitz
#18 2225681-18.patch46.79 KBquietone
#14 interdiff-2225681-12-14.txt643 bytesquietone
#14 2225681-14.patch46.83 KBquietone
#12 interdiff-2225681-10-12.txt972 bytesquietone
#12 2225681-12.patch46.84 KBquietone
#10 interdiff-2225681-8-10.txt14.92 KBquietone
#10 2225681-10.patch46.84 KBquietone
#8 2225681-8.patch34.22 KBquietone
#6 2225681-6.patch6.06 KBquietone
#40 interdiff-34-40.txt1.03 KBAda Hernandez
#40 migrate_d6_i18n_blocks-2225681-40.patch46.36 KBAda Hernandez
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pcambra’s picture

Assigned: penyaskito » Unassigned
Issue summary: View changes
phenaproxima’s picture

Project: IMP » Drupal core
Version: » 8.0.x-dev
Component: Code » migration system
phenaproxima’s picture

svendecabooter’s picture

Status: Postponed » Active

Unblocked

quietone’s picture

Issue tags: -drupal6 +migrate-d6-d8
quietone’s picture

FileSize
6.06 KB

Just a beginning. This migrates the block title from the i18n_strings table.

Needs the source data from #2670170: Add i18n string & variable data to d6_dump and destination plugins in #2225717: Add config translation support to migrations and implement for Drupal 6 user profile fields.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

quietone’s picture

Status: Active » Needs review
FileSize
34.22 KB

Consider this a first draft. It does migrate the translations for the title and the block content, using the existing block migrations as models. It may not be the best or most efficient method.

Status: Needs review » Needs work

The last submitted patch, 8: 2225681-8.patch, failed testing.

quietone’s picture

Status: Needs work » Needs review
FileSize
46.84 KB
14.92 KB

Forgot to add language manager to the other destination entities.

Status: Needs review » Needs work

The last submitted patch, 10: 2225681-10.patch, failed testing.

quietone’s picture

Status: Needs work » Needs review
FileSize
46.84 KB
972 bytes

Have no idea why $language_manager was private. Especially when tests are passing locally.

Status: Needs review » Needs work

The last submitted patch, 12: 2225681-12.patch, failed testing.

quietone’s picture

quietone’s picture

Status: Needs work » Needs review

Let's test this.

Status: Needs review » Needs work

The last submitted patch, 14: 2225681-14.patch, failed testing.

The last submitted patch, 14: 2225681-14.patch, failed testing.

quietone’s picture

Status: Needs work » Needs review
FileSize
46.79 KB

Reroll, and the interdiff fails.

Status: Needs review » Needs work

The last submitted patch, 18: 2225681-18.patch, failed testing.

Gábor Hojtsy’s picture

Issue tags: +D8MI, +language-content

Thanks for working on this :)

  1. index e3582c5..8701631 100644
    --- a/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php
    
    --- a/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php
    +++ b/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php
    
    +++ b/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php
    @@ -6,6 +6,7 @@
    
    @@ -6,6 +6,7 @@
     use Drupal\Core\Entity\EntityStorageInterface;
     use Drupal\Core\Entity\Query\QueryFactory;
     use Drupal\Core\Field\FieldTypePluginManagerInterface;
    +use Drupal\Core\Language\LanguageManagerInterface;
     use Drupal\Core\State\StateInterface;
    

    Why do comments need to change here?

  2. +++ b/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php
    --- /dev/null
    +++ b/core/modules/config_translation/migration_templates/d6_i18n_block.yml
    

    Unfortunately the migration system was rearchitected to not use migration templates anymore, this needs to be modified.

  3. +++ b/core/modules/config_translation/migration_templates/d6_i18n_block.yml
    @@ -0,0 +1,70 @@
    +      map:
    +        book:
    +          0: book_navigation
    +        comment:
    +          0: views_block:comments_recent-block_1
    +        forum:
    +          0: forum_active_block
    +          1: forum_new_block
    +        locale:
    +          0: language_block
    +        node:
    +          0: node_syndicate_block
    +        search:
    +          0: search_form_block
    +        statistics:
    +          0: statistics_popular_block
    +        system:
    +          0: system_powered_by_block
    +        user:
    +          0: user_login_block
    +          1: system_menu_block:tools
    +          2: views_block:who_s_new-block_1
    +          3: views_block:who_s_online-who_s_online_block
    

    Are we supposed to only support a fixed set of blocks? :/ Can we take these from the existing block migration or do we need to list them again?

  4. +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php
    @@ -122,6 +136,19 @@ public function getIds() {
       protected function updateEntity(EntityInterface $entity, Row $row) {
    +    if ($entity instanceof TranslatableInterface) {
    +      $property = $this->storage->getEntityType()->getKey('langcode');
    +
    +      if ($row->hasDestinationProperty($property)) {
    +        $language = $row->getDestinationProperty($property);
    +
    +        if (!$entity->hasTranslation($language)) {
    +          $entity->addTranslation($language);
    +        }
    +        $entity = $entity->getTranslation($language);
    +      }
    +    }
    +
    

    This change is already made in #2225775: Migrate Drupal 6 core node translation to Drupal 8 or at least similar :)

Gábor Hojtsy’s picture

@quietone: are you still working on this?

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

iMiksu’s picture

Issue tags: +Needs reroll

Needs also an reroll against 8.2.x.

$ curl https://www.drupal.org/files/issues/2225681-18.patch | patch -p1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 47918  100 47918    0     0  72006      0 --:--:-- --:--:-- --:--:-- 72057
patching file core/modules/comment/src/Plugin/migrate/destination/EntityComment.php
patching file core/modules/config_translation/migration_templates/d6_i18n_block.yml
patching file core/modules/config_translation/src/Plugin/migrate/process/I18nBlockSettings.php
patching file core/modules/config_translation/src/Plugin/migrate/process/Substr.php
patching file core/modules/config_translation/src/Plugin/migrate/source/d6/I18nBlock.php
patching file core/modules/config_translation/tests/src/Kernel/Migrate/d6/MigrateI18nBlockTest.php
patching file core/modules/config_translation/tests/src/Unit/Plugin/migrate/source/d6/I18nBlockSourceTest.php
patching file core/modules/content_translation/migration_templates/d6_i18n_custom_block.yml
patching file core/modules/content_translation/src/Plugin/migrate/source/d6/I18nBox.php
patching file core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateI18nBlockContentTest.php
patching file core/modules/content_translation/tests/src/Unit/Plugin/migrate/source/d6/I18nBoxTest.php
patching file core/modules/file/src/Plugin/migrate/destination/EntityFile.php
Hunk #1 FAILED at 8.
Hunk #2 FAILED at 38.
Hunk #3 FAILED at 53.
Hunk #4 FAILED at 72.
4 out of 4 hunks FAILED -- saving rejects to file core/modules/file/src/Plugin/migrate/destination/EntityFile.php.rej
patching file core/modules/migrate/src/Plugin/migrate/destination/EntityConfigBase.php
patching file core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php
Hunk #1 FAILED at 7.
Hunk #2 succeeded at 23 (offset 1 line).
Hunk #3 succeeded at 58 (offset 1 line).
Hunk #4 succeeded at 83 (offset 1 line).
Hunk #5 FAILED at 137.
2 out of 5 hunks FAILED -- saving rejects to file core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php.rej
patching file core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php
Hunk #1 succeeded at 12 (offset 1 line).
Hunk #2 succeeded at 43 (offset 1 line).
Hunk #3 succeeded at 58 (offset 1 line).
Hunk #4 succeeded at 72 (offset 1 line).
Hunk #5 succeeded at 102 (offset 1 line).
patching file core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php
patching file core/modules/migrate_drupal/src/Plugin/migrate/destination/EntityFieldStorageConfig.php
patching file core/modules/user/src/Plugin/migrate/destination/EntityUser.php
Hunk #3 FAILED at 49.
Hunk #4 succeeded at 56 (offset -2 lines).
Hunk #5 succeeded at 73 (offset -2 lines).
1 out of 5 hunks FAILED -- saving rejects to file core/modules/user/src/Plugin/migrate/destination/EntityUser.php.rej
Manuel Garcia’s picture

Gave it a go at the reroll, but failed miserably... this isn't a reroll someone without good knowledge of the latest changes and what this patch is trying to achieve can do, meaning to say the reroll will have to make some changes to the original patch was doing because of what is in core nowadays.

jofitz’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
42.85 KB

Re-roll.

Status: Needs review » Needs work

The last submitted patch, 25: 2225681-25.patch, failed testing.

jofitz’s picture

Status: Needs review » Needs work

The last submitted patch, 27: 2225681-27.patch, failed testing.

jofitz’s picture

Status: Needs work » Needs review
FileSize
714 bytes
49.41 KB

Status: Needs review » Needs work

The last submitted patch, 29: 2225681-29.patch, failed testing.

jofitz’s picture

Version: 8.2.x-dev » 8.3.x-dev
Status: Needs work » Needs review

Updated version to 8.3.x.

Status: Needs review » Needs work

The last submitted patch, 29: 2225681-29.patch, failed testing.

jofitz’s picture

Status: Needs work » Needs review
FileSize
714 bytes
43.82 KB

Well this is just getting embarrassing...

Status: Needs review » Needs work

The last submitted patch, 33: 2225681-33.patch, failed testing.

jofitz’s picture

Status: Needs work » Needs review
FileSize
717 bytes
44.52 KB
Manuel Garcia’s picture

Awesome @Jo Fitzgerald thanks for working on this!

iMiksu’s picture

Status: Needs review » Needs work
Issue tags: +Novice

I was checking some coding and comment standards out of this. All of this should be novice.

  1. +++ b/core/modules/config_translation/src/Plugin/migrate/process/I18nBlockSettings.php
    @@ -0,0 +1,35 @@
    +  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    +    list($plugin, $delta, $old_settings, $title) = $value;
    +    $settings = array();
    +    $settings['label'] = $title;
    +    if ($title) {
    +      $settings['label_display'] = BlockInterface::BLOCK_LABEL_VISIBLE;
    

    Use short array syntax.

  2. +++ b/core/modules/config_translation/src/Plugin/migrate/process/I18nBlockSettings.php
    @@ -0,0 +1,35 @@
    +    list($plugin, $delta, $old_settings, $title) = $value;
    +    $settings = array();
    +    $settings['label'] = $title;
    +    if ($title) {
    +      $settings['label_display'] = BlockInterface::BLOCK_LABEL_VISIBLE;
    

    Use short array syntax

  3. +++ b/core/modules/config_translation/src/Plugin/migrate/process/Substr.php
    @@ -0,0 +1,35 @@
    +
    +/**
    + * Gets a substring.
    + *
    + * @MigrateProcessPlugin(
    + *   id = "substr"
    + * )
    + */
    +
    +class Substr extends ProcessPluginBase {
    +
    +  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    +    $start = isset($this->configuration['start']) ? $this->configuration['start'] : 0;
    

    Unnecessary extra newline. Shouldn't have any. See "Plugin discovery annotations" from comment standards.

  4. +++ b/core/modules/config_translation/src/Plugin/migrate/source/d6/I18nBlock.php
    @@ -0,0 +1,99 @@
    +use Drupal\migrate\Row;
    +use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
    +/**
    + * Gets i18n string block data from source database.
    + *
    + * @MigrateSource(
    

    Needs a blank line between use declarations and comment block. See "Identing" from coding standards.

  5. +++ b/core/modules/config_translation/src/Plugin/migrate/source/d6/I18nBlock.php
    @@ -0,0 +1,99 @@
    +    $query = $this->select('i18n_strings', 'i18n')
    +      ->fields('i18n', array('lid', 'type', 'property', 'objectid'))
    +      ->fields('lt', array('lid', 'language', 'translation'))
    +      ->fields('b', array('bid', 'module', 'delta', 'theme'))
    +      ->condition('i18n.type', 'block');
    +    $query->leftJoin($this->blockTable, 'b', 'b.bid = i18n.objectid');
    

    Use short array syntax.

  6. +++ b/core/modules/config_translation/src/Plugin/migrate/source/d6/I18nBlock.php
    @@ -0,0 +1,99 @@
    +  public function fields() {
    +    return array(
    +      'bid' => $this->t('The block numeric identifier.'),
    +      'module' => $this->t('The module providing the block.'),
    +      'delta' => $this->t('The block\'s delta.'),
    +      'theme' => $this->t('Which theme the block is placed in.'),
    +      'language' => $this->t('Language for this field.'),
    +      'property' => $this->t('Name of property being translated.'),
    +      'translation' => $this->t('Translation of either the title or explanation.'));
    +  }
    +
    

    Use short array syntax here and check indenting that it closes in its own line.

  7. +++ b/core/modules/config_translation/src/Plugin/migrate/source/d6/I18nBlock.php
    @@ -0,0 +1,99 @@
    +    $ids['theme']['type'] = 'string';
    +    $ids['language']['type'] = 'string';
    +    return $ids;
    +  }
    +  /**
    +   * {@inheritdoc}
    +   */
    

    Needs a blank line.

  8. +++ b/core/modules/content_translation/src/Plugin/migrate/source/d6/I18nBox.php
    @@ -0,0 +1,102 @@
    +      ->fields('i18n', array('lid', 'type', 'property', 'objectid'))
    +      ->fields('lt', array('lid', 'language', 'translation'))
    +      ->fields('b', array('bid', 'body', 'info', 'format'))
    

    Use short array syntax.

  9. +++ b/core/modules/content_translation/src/Plugin/migrate/source/d6/I18nBox.php
    @@ -0,0 +1,102 @@
    +    return array(
    +      'bid' => $this->t('The block numeric identifier.'),
    +      'language' => $this->t('Language for this field.'),
    +      'body' => $this->t('The block/box content'),
    +      'info' => $this->t('Admin title of the block/box.'),
    +      'format' => $this->t('Input format of the custom block/box content.')
    

    Use short array syntax

  10. +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityConfigBase.php
    @@ -21,6 +26,53 @@
    +   * @var \Drupal\Core\Language\LanguageManagerInterface
    +   */
    +  protected $languageManager;
    +
    +  /**
    +  /**
    +   * Construct a new entity.
    +   *
    +   * @param array $configuration
    +   *   A configuration array containing information about the plugin instance.
    +   * @param string $plugin_id
    

    Double comment block starting.

Ada Hernandez’s picture

Working in this now!

Ada Hernandez’s picture

Status: Needs work » Needs review
FileSize
46.36 KB
7.73 KB

the new changes for standard commentaries and arrays were added.

Ada Hernandez’s picture

I have removed extra indents

iMiksu’s picture

Issue tags: -Novice
quietone’s picture

+++ b/core/modules/config_translation/src/Plugin/migrate/process/I18nBlockSettings.php
@@ -0,0 +1,35 @@
diff --git a/core/modules/config_translation/src/Plugin/migrate/process/Substr.php b/core/modules/config_translation/src/Plugin/migrate/process/Substr.php

Since this issue began the Substr process has been added to core. So this can be removed.

Ada Hernandez’s picture

now the core/modules/config_translation/src/Plugin/migrate/process/Substr.php was removed.

quietone’s picture

Status: Needs review » Postponed

This and a couple of other i18n issues that make changes to EntityConfigBase destintations. Of those I believe #2225717: Add config translation support to migrations and implement for Drupal 6 user profile fields has received the most feedback from Gábor Hojtsy and a review from phenaproxima (who has asked for a test for the changes to the destination).

Therefor, I am marking this as Postponed, until the destination is finalized in #2225717: Add config translation support to migrations and implement for Drupal 6 user profile fields.

Gábor Hojtsy’s picture

Yeah it would be important to commit this at one place instead of working on the same thing in parallel, thanks @quietone, was about to say the same :)

quietone’s picture

quietone’s picture

Removed core/modules/config_translation/src/Plugin/migrate/process/Substr.php.

quietone’s picture

Status: Needs review » Postponed

Oh silly me, i18n user profile isn't in. It is just RBTC.

quietone’s picture

Still, I did some cleanup and converted I18nBoxTest and I18nBockSourceTest from MigrateSqlSourceTestCase to MigrateSqlSourceTestBase.

Gábor Hojtsy’s picture

Yay, thanks! Let's hope the dependency lands soon.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

DamienMcKenna’s picture

Cross-referencing the issue that's blocking this one.

quietone’s picture

quietone’s picture

Version: 8.4.x-dev » 8.3.x-dev
Status: Needs work » Needs review
FileSize
38.55 KB

reroll

Status: Needs review » Needs work

The last submitted patch, 54: migrate_d6_i18n_blocks-2225681-54.patch, failed testing.

Gábor Hojtsy’s picture

Thanks, here is an initial review:

  1. +++ b/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php
    @@ -47,6 +55,8 @@ class EntityComment extends EntityContentBase {
    +   * @param LanguageManagerInterface $language_manager
    +   *   The language manager.
        * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
        *   The entity manager service.
        * @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager
    @@ -54,9 +64,11 @@ class EntityComment extends EntityContentBase {
    
    @@ -54,9 +64,11 @@ class EntityComment extends EntityContentBase {
        * @param \Drupal\Core\State\StateInterface $state
        *   The state storage object.
        */
    -  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager, StateInterface $state) {
    -    parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_manager, $field_type_manager);
    +  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, LanguageManagerInterface $language_manager, EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager, StateInterface $state, QueryFactory $entity_query) {
    +    parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $language_manager, $entity_manager, $field_type_manager);
         $this->state = $state;
    +    $this->entityQuery = $entity_query;
    +    $this->languageManager = $language_manager;
       }
    
    +++ b/core/modules/user/src/Plugin/migrate/destination/EntityUser.php
    @@ -50,8 +53,8 @@ class EntityUser extends EntityContentBase {
    -  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager, PasswordInterface $password) {
    -    parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_manager, $field_type_manager);
    +  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, LanguageManagerInterface $language_manager, EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager, PasswordInterface $password) {
    +    parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $language_manager, $entity_manager, $field_type_manager);
         $this->password = $password;
       }
    

    Why do we need to make these changes to comments, users, etc?

  2. +++ b/core/modules/config_translation/migration_templates/d6_i18n_block.yml
    @@ -0,0 +1,70 @@
    +    - d6_block
    +
    +
    

    Minor: too much whitespace.

  3. +++ b/core/modules/config_translation/tests/src/Kernel/Migrate/d6/MigrateI18nBlockTest.php
    @@ -0,0 +1,67 @@
    +    'views',
    +    'comment',
    +    'menu_ui',
    ...
    +    'locale',
    

    No locale needed here I believe.

    Also why do we need all of views, comment and menu UI as well?

  4. +++ b/core/modules/content_translation/src/Plugin/migrate/source/d6/I18nBox.php
    @@ -0,0 +1,103 @@
    + * Gets Drupal 6 i18n block body translation from database.
    + *
    + * @MigrateSource(
    + *   id = "d6_i18n_box"
    + * )
    + */
    +class I18nBox extends DrupalSqlBase {
    

    This is for custom content blocks, that would be a better explanation IMHO, not just bodies, they also have titles.

  5. +++ b/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateI18nBlockContentTest.php
    @@ -0,0 +1,75 @@
    +    'locale',
    

    I am not sure we need locale module for this one? Do we?

  6. +++ b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php
    @@ -66,6 +66,10 @@ class MigrateUpgradeForm extends ConfirmFormBase {
    +    'd6_i18n_block' => [
    +      'source_module' => 'translation',
    +      'destination_module' => 'config_translation',
    +    ],
         'd7_block' => [
           'source_module' => 'block',
           'destination_module' => 'block',
    @@ -82,6 +86,10 @@ class MigrateUpgradeForm extends ConfirmFormBase {
    
    @@ -82,6 +86,10 @@ class MigrateUpgradeForm extends ConfirmFormBase {
           'source_module' => 'block',
           'destination_module' => 'block_content',
         ],
    +    'd6_i18n_custom_block' => [
    +      'source_module' => 'translation',
    +      'destination_module' => 'content_translation',
    +    ],
    

    source should be i18n module (or i18nstrings or the respective i18n module) IMHO

Also finally the issue summary needs updating to explain how this covers both custom blocks (title/body) and arbitrary blocks (title).

quietone’s picture

Status: Needs work » Needs review
FileSize
38.38 KB
4.64 KB

Fixes for everything in #56.

As for the issue summary update, I think this only covers custom blocks title and body. Adding a translation for the title on the navigation block created content in the i18n_block table, which is not used in the source plugins here. If I am correct then the various changes here should be renamed by adding 'custom' to the names. And then, the new migration for block titles would use d6_i18n_block. Do I have that right?

Status: Needs review » Needs work

The last submitted patch, 57: migrate_d6_i18n_blocks-2225681-57.patch, failed testing.

quietone’s picture

Status: Needs work » Needs review
FileSize
38.38 KB
1.26 KB

Fix namespace errors.

Gábor Hojtsy’s picture

As for the issue summary update, I think this only covers custom blocks title and body. Adding a translation for the title on the navigation block created content in the i18n_block table, which is not used in the source plugins here. If I am correct then the various changes here should be renamed by adding 'custom' to the names. And then, the new migration for block titles would use d6_i18n_block. Do I have that right?

Yeah in Drupal 6 these are called boxes, in Drupal 8 they are block_content. Depending on what naming convention would the migration use, we should name them after that version's name. I think box.

quietone’s picture

OK. I took a fresh look at these block translations. Also, a good idea because the first patch I made for this was 11 months ago when I knew a lot less about migration. Not that there isn't much more to learn.

What needs to happen is migrate the block title field and the custom block title and body fields. The source tables for these are:

Blocks - 'blocks' and 'i18n_block'.
Custom blocks - 'boxes' and 'i18n_strings'.

If that is correct the rest is simpler. The source plugins are d6_i18n_block and d6_i18n_box, matching the existing d6_block and d6_box. There is no need to change any destinations, so that has been removed. And everything is in content_translation.

Probably a good idea to ignore the interdiff, it is larger than the patch.

Status: Needs review » Needs work

The last submitted patch, 61: migrate_d6_i18n_blocks-2225681-61.patch, failed testing.

quietone’s picture

Status: Needs work » Needs review
FileSize
21.13 KB
1023 bytes

Some of those errors are in tests unrelated to the patch and there is "The /var/www/html/core/modules/content_translation/migration_templates/d6_i18n_block.yml contains invalid YAML". Which it doesn't or the tests would not pass locally, so maybe the patch was corrupted?

Anyway, found a space error and a namespace error.

Status: Needs review » Needs work

The last submitted patch, 63: migrate_d6_i18n_blocks-2225681-63.patch, failed testing.

quietone’s picture

Status: Needs work » Needs review
FileSize
21.77 KB
1.37 KB

Yes, there really was an error in the d6_i18n_block.yml file but it didn't stop the local tests from passing.

This fixes the yml file and also changes it to use the migration process plugin to get the id. It seems better to do it this way since the d6_block migration uses dedupe on the id. Other i18n migration might need to do this as well. Also, fixed
MigrateBlockTest since the source not includes a translation of the title.

Gábor Hojtsy’s picture

Assigned: Unassigned » Gábor Hojtsy

Assigning for review.

Gábor Hojtsy’s picture

Assigned: Gábor Hojtsy » Unassigned

I think this looks generally good but it would be really nice to clean up some class naming and docs because its confusing which class/migration/test does what.

  1. +++ b/core/modules/content_translation/migration_templates/d6_i18n_block.yml
    @@ -0,0 +1,64 @@
    +id: d6_i18n_block
    +label: i18n Blocks
    
    +++ b/core/modules/content_translation/migration_templates/d6_i18n_custom_block.yml
    @@ -0,0 +1,27 @@
    +id: d6_i18n_custom_block
    +label: Custom blocks
    

    Its hard to tell which specific things do these migrations support, can we be more specific?

  2. +++ b/core/modules/content_translation/src/Plugin/migrate/source/d6/I18nBlock.php
    @@ -0,0 +1,104 @@
    +/**
    + * Gets i18n block data from source database.
    
    +++ b/core/modules/content_translation/src/Plugin/migrate/source/d6/I18nBox.php
    @@ -0,0 +1,103 @@
    +/**
    + * Gets Drupal 6 i18n custom block translations from database.
    

    Cleaner / more similarly structured (data vs. translation for example) descriptions would be nice to make it easier to tell which one is which one.

  3. +++ b/core/modules/content_translation/src/Plugin/migrate/source/d6/I18nBlock.php
    @@ -0,0 +1,104 @@
    +      'title' => $this->t("Title translation for this language.."),
    

    Minor: ..

  4. +++ b/core/modules/content_translation/src/Plugin/migrate/source/d6/I18nBox.php
    @@ -0,0 +1,103 @@
    +   * Merge the block body and info translations into a single row.
    +   *
    +   * @return array
    +   *   An array of ...
    +   */
    +  protected function values() {
    

    Maybe: "An array of result rows with the info keys merged in to (...)"

  5. +++ b/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateI18nBlockContentTest.php
    @@ -0,0 +1,54 @@
    +/**
    + * Tests migration of i18n block translations.
    
    +++ b/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateI18nCustomBlockContentTest.php
    @@ -0,0 +1,73 @@
    +/**
    + * Tests migration of i18n custom block strings.
    

    Cleaner description of which one is doing what would be useful.

  6. +++ b/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateI18nBlockContentTest.php
    @@ -0,0 +1,54 @@
    +class MigrateI18nBlockContentTest extends MigrateDrupal6TestBase {
    

    It says block content test, but it tests the title translation, this is confusing :/

  7. +++ b/core/modules/content_translation/tests/src/Kernel/Plugin/migrate/source/d6/I18nBlockTest.php
    @@ -0,0 +1,100 @@
    +/**
    + * Tests i18n block title source plugin.
    
    +++ b/core/modules/content_translation/tests/src/Kernel/Plugin/migrate/source/d6/I18nBoxTest.php
    @@ -0,0 +1,143 @@
    +/**
    + * Tests i18n block title source plugin.
    

    The descriptions are the same but the functionality is different.

Also I think similarly to other i18n migrations, this does not ensure the block fields themselves are marked translatable (for UI purposes). While translating the content on the API works without that, users will not be able to change or add new translations. Not 100% sure if we should do that here or not, but it needs to get done somewhere :)

quietone’s picture

Status: Needs review » Needs work
quietone’s picture

This also needs renaming. The migrations be in the form basicmigration_variation. The same pattern should be used for the related files like migration plugins and tests. See #26 and #27

quietone’s picture

Status: Needs work » Needs review
FileSize
22.05 KB
35.06 KB

First, rename migrations to use _translation as per #69.

Still need to do everything in #67.

Status: Needs review » Needs work

The last submitted patch, 70: migrate_d6_i18n_blocks-2225681-70.patch, failed testing.

quietone’s picture

Made the corrections in MigrateUpgradeForm. I think I will throw a party when #2569805: For Drupal migration, identify the source module is Fixed.

quietone’s picture

Also I think similarly to other i18n migrations, this does not ensure the block fields themselves are marked translatable (for UI purposes).

Let's do that here.

The source plugin BoxTranslation uses the same method as a version of menu link translation source plugin that alexpott kicked back with concerns about the scalability. See #39 of that issue.

quietone’s picture

Status: Needs work » Needs review

The last submitted patch, 49: migrate_d6_i18n_blocks-2225681-49.patch, failed testing.

quietone’s picture

Status: Needs review » Needs work

Back to Needs work to rework the source plugin.

quietone’s picture

Status: Needs work » Postponed

Postponing this because the source plugin test is returning false positives. #2862006: MigrateSourceTestBase returns false positives for most plugin tests

heddn’s picture

jofitz’s picture

Status: Postponed » Needs work

No longer blocked.

heddn’s picture

Priority: Normal » Major

Bumping priority while triaging the queue in the weekly migrate meeting. Getting this done is blocking completion of d6 migration path.

quietone’s picture

Status: Needs work » Needs review
FileSize
24.01 KB
12.7 KB

Reworked the source plugin.

Status: Needs review » Needs work

The last submitted patch, 81: migrate_d6_i18n_blocks-2225681-81.patch, failed testing.

quietone’s picture

Status: Needs work » Needs review
FileSize
23.55 KB
8.93 KB

Update the source plugin test and the migration to suit the new source plugin.

quietone’s picture

Status: Needs review » Needs work

Need to rename the migration as per #2861383: Rename i18n migrations to _translation.

quietone’s picture

Status: Needs work » Needs review

Ah, silly me, the renaming is already done, in #70.

jofitz’s picture

Removed redundant (debugging?) line that was highlighted as a coding standards infringement.

maxocub’s picture

Assigned: Unassigned » maxocub

Assigning for review

maxocub’s picture

Assigned: maxocub » Unassigned
Status: Needs review » Needs work

This is not a full review, I'm just trying to understand the scope of the issue since the IS seems to be outdated.

I'm have no experience with the D6 i18n module, but if I understand correctly, if you select a language for a block, the block will only appear if you are viewing the site in the selected language. Maybe this is not the scope of this issue, but I don't see this behavior being migrated here.

+++ b/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php
@@ -116,9 +116,9 @@ public function testBlockMigration() {
     $visibility = [];
     $settings = [
       'id' => 'system_menu_block',
-      'label' => '',
+      'label' => 'zu - Test Title 02',
       'provider' => 'system',
-      'label_display' => '0',
+      'label_display' => 'visible',
       'level' => 1,
       'depth' => 0,
     ];

This block is supposed to be only displayed when the site is in Zulu, so the $visibility settings should not be empty.

+++ b/core/modules/content_translation/migration_templates/d6_block_translation.yml
@@ -0,0 +1,64 @@
+id: d6_block_translation
+label: Blocks translation
+migration_tags:
+  - Drupal 6
+source:
+  plugin: d6_block_translation
+  constants:
+    dest_label: 'settings/label'

This should provide a process pipeline for the visibility settings.

quietone’s picture

Status: Needs work » Needs review

@maxocub, thanks for the review. I've been learning D6 internationalization as I work on these issues so don't have much experience.

I'll try to explain what happens when I translate a block, in this case the navigation block. On the block config page, I can choose a language for the block and the various visibility settings. If say, I choose Zulu, the label field in the blocks table is overwritten with the Zulu title and so are the visibility settings. If I then choose French, the French title and visibility settings overwrites the Zulu versions and the block can only be for French. It seems that the block can only be in one language (or all languages). The block migration will migrate the possibly translated title and the visibility settings. Then d6_block_translation, will make sure the title has the correct language code.

Make sense?

maxocub’s picture

@quietone: I think I understand what you're doing, that is migrating the string translations of the block labels?

What I understood and what I tried was:
1) Fresh D6 install
2) Enable i18nblocks
3) Add a language, say French
4) Enable path prefix for language selection
5) Go to the Blocks page
6) Configure a block, say Navigation
7) Chose French in the languages selection
8) Now, if you are seeing the site in English, you don't see the Navigation block, but if you see it in French (/fr) you see it.
9) Then if you migrate, on the D8 site the Navigation block is visible on both English and French, which is not the same behavior as on the D6 site.

If on the D8 site I configure the Main Navigation block and select French, then the visibility configuration of the block will be:

visibility:
  language:
    id: language
    langcodes:
      fr: fr
    negate: false
    context_mapping:
      language: '@language.current_language_context:language_interface'

But in the above migration scenario, the visibility configuration of the block is empty.

Am I thinking out of the scope of this issue?

quietone’s picture

@maxocub, thanks! Now I understand the problem.

Am I thinking out of the scope of this issue?

I think we should move visibility to a follow up. Even if we make the changes to migrate the visibility settings of a translated block the visibility settings for the non-translated block will be incorrect. And It doesn't seem obvious how to solve this. At least to me. Because, if I understand correctly, when migrating a french language navigation block, we also have to modify the visibility settings on the english version navigation block.

And, In favour of a followup is that this does migrate the translation and the user can fix this visibility in the UI.

So, yes, let's move migrating visibility settings on i18n blocks to a follow up.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

maxocub’s picture

Assigned: Unassigned » maxocub

Picking up for review

maxocub’s picture

Assigned: maxocub » Unassigned
Status: Needs review » Needs work

I'd like to see an issue summary update here, to make it easier for reviewers and eventually commiters.

quietone’s picture

Issue summary: View changes
Status: Needs work » Needs review
Related issues: +#2903579: Migrate translated block visibility settings

had a go at updating the IS.
A follow up has been created as discussed in #90, #91. #2903579: Migrate translated block visibility settings

maxocub’s picture

Assigned: Unassigned » maxocub
Issue tags: -Needs issue summary update

Thanks @quietone!
Assigned for review.

maxocub’s picture

Assigned: maxocub » Unassigned
Status: Needs review » Needs work

1.

+++ b/core/modules/content_translation/migration_templates/d6_block_translation.yml
 
+++ b/core/modules/content_translation/migration_templates/d6_custom_block_translation.yml

+++ b/core/modules/content_translation/src/Plugin/migrate/source/d6/BlockTranslation.php

+++ b/core/modules/content_translation/src/Plugin/migrate/source/d6/BoxTranslation.php

+++ b/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateBlockContentTranslationTest.php

+++ b/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateCustomBlockContentTranslationTest.php

+++ b/core/modules/content_translation/tests/src/Kernel/Plugin/migrate/source/d6/BlockTranslationTest.php

+++ b/core/modules/content_translation/tests/src/Kernel/Plugin/migrate/source/d6/BoxTranslationTest.php

Why do we put this in content_translation and not block and block content? Like d6_node_translation being in the node module?

2.

+++ b/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateCustomBlockContentTranslationTest.php
@@ -0,0 +1,74 @@
+    'block',
...
+    'config_translation',
...
+    'statistics',

This is not needed.

3.

+++ b/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateCustomBlockContentTranslationTest.php
@@ -0,0 +1,74 @@
+    ConfigurableLanguage::createFromLangcode('en')->save();
+    ConfigurableLanguage::createFromLangcode('fr')->save();
+    ConfigurableLanguage::createFromLangcode('zu')->save();

Instead of creating each languages, we can just add 'language' to the executed migrations.

4.
I'm not certain if it would accelerate this issue getting in, but personnaly I would have find a lot easier to understand this patch if it was split in two, one for block translation ans one for custom block translation.

maxocub’s picture

Issue tags: +Needs reroll

Oh, and it needs a re-roll, simply needs to remove the changes in MigrateUpgradeForm.php

quietone’s picture

Status: Needs work » Needs review
FileSize
22.5 KB
1.88 KB

Just the reroll.

Status: Needs review » Needs work

The last submitted patch, 99: 2225681-99.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
22.53 KB
1.13 KB

Needed to add the source_module to the source plugin annotations. Hopefully that will fix the tests and complete the reroll.

Status: Needs review » Needs work

The last submitted patch, 101: 2225681-101.patch, failed testing. View results

jofitz’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
22.41 KB
1.32 KB

Changed the source module for BoxTranslation.

Removed the redundant migrations from MigrateCustomBlockContentTranslationTest (#97.2).

maxocub’s picture

Title: Migrate D6 i18n blocks » Migrate D6 i18n blocks translated strings
Issue summary: View changes
Related issues: +#2909444: Migrate D6 i18n custom blocks (boxes)
FileSize
10.45 KB

Ok, so I took the liberty to split this patch in two for easier reviews & commit, one problem/solution per issue. This one now deals with block translated string migration, and the other one, #2909444: Migrate D6 i18n custom blocks (boxes), deals with custom blocks (boxes) translations migration.
No change has been made to the remaining code.

maxocub’s picture

Status: Needs review » Needs work

1.

+++ b/core/modules/content_translation/migration_templates/d6_block_translation.yml
@@ -0,0 +1,64 @@
+label: Blocks translation

Nit: Block translations?

2.

+++ b/core/modules/content_translation/src/Plugin/migrate/source/d6/BlockTranslation.php
@@ -0,0 +1,104 @@
+      ->fields('b', ['bid', 'module', 'delta', 'theme', 'title']);
+    $query->addField('b', 'module', 'block_module');
+    $query->addField('b', 'delta', 'block_delta');

These can be chained.

3.

+++ b/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php
--- /dev/null
+++ b/core/modules/content_translation/migration_templates/d6_block_translation.yml

+++ b/core/modules/content_translation/migration_templates/d6_block_translation.yml
--- /dev/null
+++ b/core/modules/content_translation/src/Plugin/migrate/source/d6/BlockTranslation.php

+++ b/core/modules/content_translation/src/Plugin/migrate/source/d6/BlockTranslation.php
--- /dev/null
+++ b/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateBlockContentTranslationTest.php

+++ b/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateBlockContentTranslationTest.php
--- /dev/null
+++ b/core/modules/content_translation/tests/src/Kernel/Plugin/migrate/source/d6/BlockTranslationTest.php

I'm not sure that content_translation is the right place for this code. I think it should go in block, like the node translation migrations are in the node module.

4.

+++ b/core/modules/content_translation/tests/src/Kernel/Plugin/migrate/source/d6/BlockTranslationTest.php
@@ -0,0 +1,100 @@
+ * Tests i18n block title source plugin.

This comment needs to be updated.

jofitz’s picture

Status: Needs work » Needs review
FileSize
16.04 KB
10.34 KB
  1. Label changed.
  2. These cannot be chained because addField() returns "The unique alias that was assigned for this field".
  3. Moved files from content_translation to block.
  4. Updated the comment.

Status: Needs review » Needs work

The last submitted patch, 106: 2225681-106.patch, failed testing. View results

jofitz’s picture

Status: Needs work » Needs review
FileSize
10.16 KB
  • Moved files to the correct location (block, not block_content).
  • Update namespace in files.

Status: Needs review » Needs work

The last submitted patch, 108: 2225681-108.patch, failed testing. View results

jofitz’s picture

Put d6_block_translation source plugin in a d6 sub-directory.

Status: Needs review » Needs work

The last submitted patch, 110: 2225681-110.patch, failed testing. View results

maxocub’s picture

  1. +++ b/core/modules/block/src/Plugin/migrate/source/d6/BlockTranslation.php
    @@ -0,0 +1,104 @@
    +    if ($this->getModuleSchemaVersion('system') >= 7000) {
    +      $this->blockTable = 'block';
    +    }
    +    else {
    +      $this->blockTable = 'blocks';
    +    }
    

    We are putting this in the d6 namespace and we are checking if we are dealing with D6 or D7. We should do one or the other. I think this source plugin should also work with D7, but we should confirm that before.

  2. +++ b/core/modules/block/tests/src/Kernel/Plugin/migrate/source/BlockTranslationTest.php
    @@ -0,0 +1,100 @@
    +namespace Drupal\Tests\block\Kernel\Plugin\migrate\source\d6;
    

    The namespace doesn't match the file location. This will depend on where we put the source plugin.

maxocub’s picture

Re #112:

  1. I checked and it seems like the source plugin won't work with D7. There's no i18n_blocks table in D7, the translations are stored in i18n_string. So the plugin should stay in the d6 namespace but we should remove the getModuleSchemaVersion() call and just hardcode the blocks table name.
  2. We should move BlockTranslationTest in a d6 folder to match the namespace. This should fix the failing test.
jofitz’s picture

Status: Needs work » Needs review
FileSize
1.25 KB
9.89 KB
  1. Hard-coded blocks table name and removed all (now-redundant) references to blockTable.
  2. Moved BlockTranslationTest to a d6 sub-folder.
maxocub’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Vienna2017

Every concerns have been addressed, I think this is ready to be RTBCed.

quietone’s picture

@Jo Fitzgerald and @maxocub thanks for getting this to RTBC. Wanting to get this done in Vienna. And you all did it!

phenaproxima’s picture

Status: Reviewed & tested by the community » Needs work

This patch looks very, very good overall. So nice and clear, and good test coverage. I did find a few concerns, though.

  1. +++ b/core/modules/block/src/Plugin/migrate/source/d6/BlockTranslation.php
    @@ -0,0 +1,90 @@
    + *   source_module = "block"
    

    This needs to be i18n_block, or whichever module it is that actually creates the i18n_blocks table. Pretty sure it ain't the block module, though. =\

  2. +++ b/core/modules/block/src/Plugin/migrate/source/d6/BlockTranslation.php
    @@ -0,0 +1,90 @@
    +      ->fields('b', ['bid', 'module', 'delta', 'theme', 'title']);
    +    $query->addField('b', 'module', 'block_module');
    +    $query->addField('b', 'delta', 'block_delta');
    

    Nit: Let's take module and delta out of the call to fields(), since we're including them again in the addField() calls.

  3. +++ b/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php
    @@ -116,9 +116,9 @@ public function testBlockMigration() {
    -      'label' => '',
    +      'label' => 'zu - Test Title 02',
           'provider' => 'system',
    -      'label_display' => '0',
    +      'label_display' => 'visible',
    

    I don't understand why these changed, in this test.

  4. +++ b/core/modules/migrate_drupal/tests/fixtures/drupal6.php
    @@ -746,7 +746,7 @@
    -  'title' => '',
    +  'title' => 'zu - Test Title 02',
    

    Why this change in the block table? That seems incorrect.

quietone’s picture

#117.4) I was originally surprised when learning about translated blocks how the data is stored in the block table. When making changes to the source db, I use the UI and watch what happens to the database tables. When adding the Zulu translation the translation was put in a row in the block table. This change reflects that.
#117.3) The translation was updated so, update the test string. I think the visibility can be restored to the original, there is a follow up issue for visibility settings.

dipakmdhrm’s picture

This fixes Observion #1 & #2 from comment #117.

However, #3 & #4 are a little tricky.

If we change the Block title in the fixture from empty value to a string. Tests in MigrateBlockTest.php expect the label to be visible. Don't know why... I am hoping that the answer is "Blocks are weird"....

And thus if we have a non-empty title for the block in fixture, we need the test to expect the lable to be visible. ¯\_(ツ)_/¯

dipakmdhrm’s picture

Status: Needs work » Needs review

Forgot to put this in review.... :(

quietone’s picture

Regrarding #117.3) There has been some discussion and questioning the change to 'label_display' in the test. That setting is migrated in d6_block, specifically the process plugin block_settings. In that process, if the title field is populated in the d6 source then the label_display will be 'visible'. The relevant code is:

if ($title) {
      $settings['label_display'] = BlockPluginInterface::BLOCK_LABEL_VISIBLE;
    }
    else {
      $settings['label_display'] = '0';
    }

So, the change to the test is correct.

Status: Needs review » Needs work

The last submitted patch, 119: 2225681-119.patch, failed testing. View results

phenaproxima’s picture

  1. +++ b/core/modules/block/src/Plugin/migrate/source/d6/BlockTranslation.php
    @@ -0,0 +1,90 @@
    +class BlockTranslation extends DrupalSqlBase {
    

    Is there any reason this class could not extend the Block source plugin, and add i18n stuff to query()? This would reduce the amount of code we need here...

  2. +++ b/core/modules/block/tests/src/Kernel/Plugin/migrate/source/d6/BlockTranslationTest.php
    @@ -0,0 +1,100 @@
    +class BlockTranslationTest extends MigrateSqlSourceTestBase {
    

    If we make BlockTranslation extend Block, this test could maybe extend Block's test too.

jofitz’s picture

Status: Needs work » Needs review
FileSize
8.69 KB
4.21 KB

@phenaproxima I have made the changes you suggested, but I'm not entirely convinced of the benefits - can you persuade me?

quietone’s picture

@Jo Fitzgerald, thanks! I was working on this but then webchick came by to do some commits.

Status: Needs review » Needs work

The last submitted patch, 124: 2225681-124.patch, failed testing. View results

jofitz’s picture

Aww, I screwed that up, didn't I! @quietone Feel free to take over, I'm calling it a day and going home for the weekend!

dipakmdhrm’s picture

Status: Needs work » Needs review
FileSize
16.39 KB
758 bytes

quiteone's original patch had a query in BlockTranslation class that did a left join from i18n_blocks table to blocks table to get all the translated blocks.

jo-fitzgerald's patch in #128 made a change to base BlockTranslation on Block, but this changed the query and the new query had a left joind from blocks table to i18n_blocks table which resulted in null values for some blocks.

I've updated the code to do an innerJoin between blocks & i18n_blocks to get only the required translated blocks.

The last submitted patch, 128: 2225681-128.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 128: interdiff-124-128.diff, failed testing. View results

dipakmdhrm’s picture

Patch in 128 failed to apply because I created the patch on 8.5.x version and somehow managed to get unwanted code in the diff.
Patch in 128 should be completely disregarded.

Changing patch to 8.4.x.

Changes mentioned in 128 still apply though.

dipakmdhrm’s picture

Status: Needs work » Needs review
quietone’s picture

Status: Needs review » Needs work

One more thing! I think that the intent of #123.2, extending the source plugin test, hasn't been addressed.

+++ b/core/modules/block/tests/src/Kernel/Plugin/migrate/source/d6/BlockTranslationTest.php
@@ -0,0 +1,95 @@
+    $tests = parent::providerSource();

This is the first time, that I can think of, that a source plugin test extends from the parent. That is ok, but this is not clear at all what is the difference between this test and the parent test. And looking at the parent it seems that currently every array in $tests is overwritten, which means this line is not doing anything except confusing the reader. How about we keep this line but just change those array values that are different. That has the advantage that we can quickly see the necessary changes for this test.

quietone’s picture

From #105.3,

I'm not sure that content_translation is the right place for this code. I think it should go in block, like the node translation migrations are in the node module.

This has been niggling at me for a while. And now back at home it is clear to me why I put in content_translation.

The node translation migrations can be in the node module because it uses the same source plugin as non-translated node. But for blocks, a new source plugin is needed because both the block table and the i18n_blocks table are required.

When block is enabled on the destination site this block translation migration will be discovered but the source site may not have translations. Without the existence of all the source tables the migration will generate an error about 'base table or view not found'. And for those with a single language site this will be confusing and just plain wrong. This can be avoided by moving the block translation code to content_translation. That way the block translation migration is only discovered when content_translation is enabled, which is needs to be to translate blocks.

Therefor this should be moved back to content_translations.

maxocub’s picture

@quietone: Thanks for the clarification, I had not realized that, so I agree that this should go in content_trnaslation.

jofitz’s picture

Status: Needs work » Needs review
FileSize
8.39 KB
12.42 KB

Changes in response to #133 and #134:

  • Moved back to content_translations.
  • Tweaked BlockTranslationTest to make better use of the data from the parent.

I would appreciate opinions on a change I made in the name of extension: previously the query() function of BlockTranslation contained a leftJoin from i18n_blocks to block. In trying to extend Block I switched the tables which of course did not work. @dipakmdhrm found a solution by replacing the leftJoin with innerJoin, but I'm not comfortable with this because it is not a like-for-like replacement. Ideally it would be a rightJoin, but that has been deprecated. Do we have to drop the call to parent::query() in BlockTranslation::query() (which would make life complicated because it also seta a few properties) or is the innerJoin acceptable?

I've struggled to even put this question into words let alone answer it so hopefully someone else will understand what I'm talking about and will have an answer!

phenaproxima’s picture

Status: Needs review » Needs work

This looks quite good. Only a few minor things.

  1. +++ b/core/modules/content_translation/migration_templates/d6_block_translation.yml
    @@ -0,0 +1,64 @@
    +  id:
    +    plugin: migration
    +    migration: d6_block
    +    source:
    +      - module
    +      - delta
    

    This should be using the migration_lookup plugin, not migration. Additionally, should we skip the row if the migration_lookup comes back empty?

  2. +++ b/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateBlockContentTranslationTest.php
    @@ -0,0 +1,60 @@
    +  public static $modules = [
    

    This should be protected.

  3. +++ b/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateBlockContentTranslationTest.php
    @@ -0,0 +1,60 @@
    +    $config = \Drupal::service('language_manager')->getLanguageConfigOverride('zu', 'block.block.user_1');
    

    Let's use $this->container rather than \Drupal::service().

  4. +++ b/core/modules/content_translation/tests/src/Kernel/Plugin/migrate/source/d6/BlockTranslationTest.php
    @@ -0,0 +1,72 @@
    +  public static $modules = ['content_translation'];
    

    Should be protected.

Do we have to drop the call to parent::query() in BlockTranslation::query() (which would make life complicated because it also seta a few properties) or is the innerJoin acceptable?

If innerJoin() is not ideal, then we should use whatever way is most ideal. It seems to me that dropping the call to parent::query(), and copy-pasting the code from the parent method, is the way to go so that we can use the non-deprecated leftJoin(), which is the documented replacement for rightJoin(). As long as we have a comment explaining the copypasta, I'm OK with that.

jofitz’s picture

Status: Needs work » Needs review
FileSize
8.48 KB
1.65 KB

A couple of changes and a question back to @phenaproxima:

  1. Changed the plugin, skip the row if it comes back empty.
  2. Why should it be protected? Many (29) occurrences are protected, but most (100+) are public.
  3. Used $this->container.
  4. See 2.
quietone’s picture

FileSize
8.73 KB
2.93 KB
8.73 KB
1.27 KB

@Jo Fitzgerald, thanks. And here is an update to the source plugin query.

quietone’s picture

Ah, silly thing. I was uploading patch but Jo Fitzgerald beat me to it. Patch -139 has the changes to the source plugin query.

phenaproxima’s picture

Why should it be protected? Many (29) occurrences are protected, but most (100+) are public.

It was changed in the base classes (KernelTestBase et. al.), so we should change it down the line. There is no reason for the $modules property to be publicly exposed. That said, in the context of this issue, it's a nitpick we don't need to bother with.

I did find one superdupernit, fixable on commit.

+++ b/core/modules/content_translation/src/Plugin/migrate/source/d6/BlockTranslation.php
@@ -0,0 +1,53 @@
+    // Let the parent set the block table to use but do not use the parent query.

This line should be 80 characters long. :)

If the tests pass, I think this one is ready for RTBC.

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

Okay. All seems legit here. RTBC for patch-139 in #139.

jofitz’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
8.71 KB
2.32 KB

It only takes a moment to resolve those minor nits.

jofitz’s picture

Status: Needs review » Reviewed & tested by the community

The changes are so minor that this can be safely returned to RTBC.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 143: 2225681-143.patch, failed testing. View results

jofitz’s picture

Status: Needs work » Needs review
FileSize
8.71 KB
915 bytes
1.35 KB

So it seems that making $modules protected is a little more involved - it needs to be changed 'all the way up the chain' on all of its ancestor classes too otherwise an error occurs.

As @phenaproxima said this is "a nitpick we don't need to bother with" (and for simplicity's sake) I have removed this change. Perhaps we could have a follow-up ticket that changes all instances of $modules to protected?

jofitz’s picture

Status: Needs review » Reviewed & tested by the community

Surely this change can be safely set back to RTBC... (famous last words)

phenaproxima’s picture

That sounds good. Sorry about the wild goose chase.

Will you open a follow-up to convert all Migrate tests to the new standard? Then I think we’re done here...

quietone’s picture

Gábor Hojtsy’s picture

Looking at the patch, I am not convinced this is migrating what the D6 translation system means with the blocks (based on the above discussions especially between @maxocub and @quietone), so will try to reproduce the D6 examples from @maxocub above soon.

Gábor Hojtsy’s picture

Now more than a week passed but I did not get around to test D6 i18n earlier, sorry for that. What I wanted to verify is what feature is covered by this migration. Steps I did:

1. Installed D6 with i18n.
2. Enabled block translation (this enabled string translation and locale).
3. Added Hungarian, enabled path prefix negotiation.
4. Enabled the Who's online block but retitled as "Whooooose online" (otherwise source string would not show up for locale).
5. Locale table indicated there is 1 untranslated block title now for Hungarian.
6. Went to translate that.

This made the block title show up translated in Hungarian when visiting /hu on the site. The feature here does not require tying the block to a specific language, so I agree with @quietone that no migration for that is required to solve this. I was also concerned that we are migrating this to a translation and not to a block in a specific language, but that also seems correct, since that is what D6 does.

So this looks good as-is to me :)

Not committing yet as we are in the middle of doing a core patch release.

Gábor Hojtsy’s picture

Version: 8.4.x-dev » 8.5.x-dev
catch’s picture

+++ b/core/modules/content_translation/migration_templates/d6_block_translation.yml
@@ -0,0 +1,68 @@
+        - delta
+      map:
+        book:
+          0: book_navigation
+        comment:
+          0: views_block:comments_recent-block_1
+        forum:
+          0: forum_active_block
+          1: forum_new_block
+        locale:
+          0: language_block
+        node:
+          0: node_syndicate_block
+        search:
+          0: search_form_block
+        statistics:
+          0: statistics_popular_block
+        system:
+          0: system_powered_by_block
+        user:
+          0: user_login_block
+          1: system_menu_block:tools
+          2: views_block:who_s_new-block_1
+          3: views_block:who_s_online-who_s_online_block
+    -

I understand the reason for the mapping, but what happens with contrib blocks here? Or would people need to build a custom migration off this one?

phenaproxima’s picture

That mapping was copy-and-pasted from the d6_block migration, which has been that way since forever.

I don't know if it's documented anywhere, but contrib migrations would need to implement hook_migration_info_alter() and change the map so as to include the proper mappings for the blocks they provide. Core's migrations are only concerned with core's blocks.

This is very likely an aspect of the API (such as it is) that should be documented, so should we open a follow-up issue...?

Gábor Hojtsy’s picture

@catch: the existing d7_block and d6_block migration templates contain the same hardcoded list already so this is not a new thing :)

  • Gábor Hojtsy committed b53e50d on 8.5.x
    Issue #2225681 by quietone, Jo Fitzgerald, dipakmdhrm, Adita, maxocub,...
Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Given the above discussion I think this is still good to go. I did not find concerns with the code and verified the source data is considered well, so committed! Thanks all for working on this, it was a long way :)

  • xjm committed 4381296 on 8.5.x
    Revert "Issue #2225681 by quietone, Jo Fitzgerald, dipakmdhrm, Adita,...
xjm’s picture

Status: Fixed » Needs work

The migration_templates directory was just deprecated, but this introduced new usages of it (which now causes HEAD to fail). So I reverted this and we need to update the patch to use the migrations directory instead. Thanks!

quietone’s picture

Issue tags: +Novice

Tagging as novice.

The task is to rename the directory migration_templates to migration. That's all.

RytoEX’s picture

I've attempted to address #159 and #160. As this is my first attempt to contribute on Drupal.org, feel free to let me know if I've mucked it up. There seems to be multiple suggested naming conventions for patches, so I used [issue_id]-[new_comment_number], which seems to have been used here.

quietone’s picture

@RytoEX, Welcome! This patch is great! I agree that there are a few ways people name patches, but they always have the issue number and comment number, which you have done. The only problem is that I typed 'migration' instead of 'migrations' as the new directory name. You up for more practice at making a patch? (I've been plagued by typos lately and my reviewing skill hasn't caught up to the extra work.)

RytoEX’s picture

@quietone No problem. I've provided a new patch per #162 and new interdiffs against #146 and #161.

heddn’s picture

Seems like a legit failure. Why can't it find d6_block_translation migration?

quietone’s picture

Status: Needs work » Needs review
Issue tags: -Novice
FileSize
9.46 KB
583 bytes

i18n blocks was in the list returned by getMissingPaths.

ao2’s picture

With the patch from #165 I get this error while trying to migrate a site:

Did not save to map table due to NULL value for key field theme                                                                                     [error]
Processed 6 items (2 created, 0 updated, 0 failed, 4 ignored) - done with 'ao2_it_d6_block_translation'                                             [status]

I can post parts of the blocks and i18n_block tables on the d6 site if needed.

quietone’s picture

@ao2, yes, please post the data, that will help. And also, please not if you have any contrib or custom modules that would be altering those tables. Thx.

ao2’s picture

I don't think I have extra modules altering the blocks and i18n_blocks tables, but the issue seems to happen because of some spurious data in i18n_blocks.

The problem is about menu blocks, I have:

SELECT * FROM `i18n_blocks`

ibid	module	delta			type	language
1	menu	menu-link-primari	0	it
3	menu	menu-primary-links	0	en
4	menu	menu-link-primary	0	it
...

The first row has a delta value which is not present in the blocks table.

SELECT * FROM `blocks`  WHERE `module` = 'menu'

bid	module	delta			theme	status	weight	region	custom	throttle	visibility	pages	title	cache
5	menu	primary-links		garland	1	-6	right	0	0		0				-1
6	menu	secondary-links		garland	0	0		0	0		0				-1
15	menu	secondary-links		ao2	0	-14		0	0		0				-1
20	menu	primary-links		ao2	0	-11		0	0		0				-1
38	menu	menu-primary-links	ao2	1	-14	left	0	0		0				-1
39	menu	menu-link-primary	ao2	1	-13	left	0	0		0				-1
47	menu	menu-projects		ao2	1	-12	left	0	0		0				-1

The fact that "primari" is the italian translation of "primary" makes me think that I could have changed the block description at some point and some i18n bug resulted in a duplicate entry in i18n_blocks. Or maybe I deleted and recreated a menu and the code didn't remove the entry from i18n_blocks, I can't really remember because it was many years ago.

Anyways the data results in the query performed by core/modules/content_translation/src/Plugin/migrate/source/d6/BlockTranslation.php to return NULL values:

SELECT i18n.ibid AS ibid, i18n.module AS module, i18n.delta AS delta, i18n.type AS type, i18n.language AS language, b.bid AS bid, b.module AS b_module, b.delta AS b_delta, b.theme AS theme, b.title AS title, b.module AS block_module, b.delta AS block_delta FROM i18n_blocks i18n LEFT OUTER JOIN blocks b ON b.module = i18n.module AND b.delta = i18n.delta

ibid	module	delta			type	language	bid	b_module	b_delta			theme	title	block_module	block_delta
3	menu	menu-primary-links	0	en		38	menu		menu-primary-links	ao2		menu		menu-primary-links
4	menu	menu-link-primary	0	it		39	menu		menu-link-primary	ao2		menu		menu-link-primary
...
1	menu	menu-link-primari	0	it		NULL	NULL		NULL			NULL		NULL		NULL

The last row has NULL values.

Using an INNER JOIN instead of a LEFT JOIN in BlockTranslation.php seems to fix the issue, at least here.

quietone’s picture

Issue summary: View changes

So the problem reported by ao2, which appears to be caused by bad data in i18n_blocks, is fixed by a changing the query to use an inner join.
Interestingly this approach was used earlier in this patch, see #128, in response to phenaproxima's suggestions in #123. The query was changed to use an inner join to fix the same problem that ao2 encountered.

So, do we use an inner join, or solve the 'bad data' situation in another way?

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

heddn’s picture

Assigned: Unassigned » quietone
Status: Needs review » Needs work
Issue tags: +Needs tests

Before we add/remove/change the join here, can we get a test that reproduces the issue in all its glory?

quietone’s picture

Status: Needs work » Needs review
FileSize
9.48 KB
968 bytes

Needed a reroll.

Status: Needs review » Needs work

The last submitted patch, 172: 2225681-172.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
10.29 KB
623 bytes

Forgot to update MigrateUpgrade6ReviewPageTest

quietone’s picture

Status: Needs review » Needs work

NW for tests

quietone’s picture

Assigned: quietone » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
16.83 KB
16.83 KB
8.7 KB

Using the UI I managed to do the magical steps to create a failure, just like that reported by ao2 in #168. I used the hint there and created translated menus and blocks and then deleted a menu. It actually wasn't that difficult, but I did not keep notes of the steps.

The results are an i18n_blocks table with 3 new entries and a blocks table that does not have an entry for one of the those, specifically ibid = 2.

MariaDB [dev2_dump]> select * from i18n_blocks;
+------+--------+-------------------------+------+----------+
| ibid | module | delta                   | type | language |
+------+--------+-------------------------+------+----------+
|    1 | user   | 1                       |    0 | zu       | migrated
|    2 | block  | 3                       |    0 | fr       | Causes error with left join
|    3 | menu   | secondary-links         |    0 | en       | ignored because customized = 0
|    4 | menu   | menu-fr-secondary-links |    0 | fr       | migrated
+------+--------+-------------------------+------+----------+
4 rows in set (0.00 sec)

The fail patch uses the left join and the patch uses an inner join.

The last submitted patch, 176: 2225681-fail-176.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 176: 2225681-176.patch, failed testing. View results

jofitz’s picture

Status: Needs work » Needs review
FileSize
2.55 KB
18.12 KB

Fix a couple of test failures by matching with changes to the fixture.

Minor correction to a variable type.

Status: Needs review » Needs work

The last submitted patch, 179: 2225681-179.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
18.18 KB
506 bytes

And content tag to the migration.

Status: Needs review » Needs work

The last submitted patch, 181: 2225681-181.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
18.19 KB
525 bytes

Used the wrong tag in the new migration.

Status: Needs review » Needs work

The last submitted patch, 183: 2225681-183.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
18.19 KB
1.92 KB

Needed a reroll.

Status: Needs review » Needs work

The last submitted patch, 185: 2225681-185.patch, failed testing. View results

quietone’s picture

This is failing on menu links (node/11 and node/13, which become node/10 and node/13) and needs to be tested with #2225587: Migrate D6 i18n menu links installed.

quietone’s picture

Issue summary: View changes
Status: Needs work » Postponed

So, let's postpone on that and avoid some rerolling.

heddn’s picture

Status: Postponed » Needs review

No longer blocked.

quietone’s picture

Retesting latest patch

Status: Needs review » Needs work

The last submitted patch, 185: 2225681-185.patch, failed testing. View results

quietone’s picture

Issue tags: +Needs reroll

Yes, needs a reroll

yogeshmpawar’s picture

Assigned: Unassigned » yogeshmpawar

Assigning myself for Re-roll.

yogeshmpawar’s picture

Assigned: yogeshmpawar » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
18.04 KB

Re-rolled the patch against 8.6.x branch.

Status: Needs review » Needs work

The last submitted patch, 194: 2225681-194.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
18.52 KB

@Yogesh Pawar, thanks for the reroll. It can be tedious to reroll when the database dump is involved.

I've opted to make a reroll from the patch in #183 because when the dump is involved I prefer to go through it myself and that helps me find errors. Let's see what errors this patch generates.

Status: Needs review » Needs work

The last submitted patch, 196: 2225681-196.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
18.26 KB

When I made the previous patch I forgot to dump the database file. This will take care of that mistake.

Status: Needs review » Needs work

The last submitted patch, 198: 2225681-198.patch, failed testing. View results

quietone’s picture

Just noting the error is from the menu 'fr -Test 2'.

Warning: array_walk() expects parameter 1 to be array, string given in Drupal\Core\Utility\LinkGenerator->generate() (line 119 of core/lib/Drupal/Core/Utility/LinkGenerator.php).

Drupal\Core\Utility\LinkGenerator->generate('fr -Test 2', Object) (Line: 94)
Drupal\Core\Render\Element\Link::preRenderLink(Array)
call_user_func(Array, Array) (Line: 378)
quietone’s picture

The failures are due to one of the changes made to the test fixture in #176. That change was an addition of a french only menu and while that causes errors and needs some investigation that it outside the scope of this issue. I removed that and a full migration was successful locally so I assume that MigrateUpgrade6 will pass. The change needed to test the problem that ao2 identified remains in the test fixture.

To confirm that this still fixes the problem identified by ao2 where an inner join is needed a fail patch is included that uses a left join. Let's see if testbot agrees.

The last submitted patch, 201: 2225681-201.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 201: 2225681-201-fail.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
18.1 KB
898 bytes

Now fix the entity counts.

quietone’s picture

I've been wanting to simplify the changes to the test fixture and reroll the patch. And here is that attempt.

The changes to the test fixture are now;
1) Add a translation of the title of the Navigation block
2) Add a new menu 'Translation test'. Then configure the 'Translation test' block and a translation of the title. Then delete the menu 'Translation test'. That adds a row to the i18n_blocks table with NULLs which replicates the problem reported by ao2.

Status: Needs review » Needs work

The last submitted patch, 205: interdiff-fail.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
898 bytes
13.1 KB

Oh yes, and restore the entity counts.

Status: Needs review » Needs work

The last submitted patch, 207: 2225681-207.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
11.27 KB
2.43 KB

Fix the remaining tests.

maxocub’s picture

Assigned: Unassigned » maxocub

Assinging for review

maxocub’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

This will need a re-roll.

Other than that, just a few nits:

  1. +++ b/core/modules/content_translation/migrations/d6_block_translation.yml
    @@ -0,0 +1,69 @@
    +  constants:
    +    dest_label: 'settings/label'
    

    This constant is only used one time. Does it need to be a constant?

  2. +++ b/core/modules/content_translation/src/Plugin/migrate/source/d6/BlockTranslation.php
    @@ -0,0 +1,54 @@
    +    // Let the parent set the block table to use, but do not use the parent
    +    // query. Instead build a query so can use a left join to the selected block
    +    // table.
    +    parent::query();
    

    Looking at the namespace and the plugin ID, this plugin is only used for D6, so I don't think we need to do parent::query(). The block table will always be the same.

  3. +++ b/core/modules/content_translation/src/Plugin/migrate/source/d6/BlockTranslation.php
    @@ -0,0 +1,54 @@
    +      ->fields('b', ['bid', 'module', 'delta', 'theme', 'title']);
    +    $query->addField('b', 'module', 'block_module');
    +    $query->addField('b', 'delta', 'block_delta');
    

    Since we add the module & delta fields with addField(), we can remove them from fields().

maxocub’s picture

Assigned: maxocub » Unassigned
quietone’s picture

Status: Needs work » Needs review
FileSize
11.29 KB

Start with a reroll

Status: Needs review » Needs work

The last submitted patch, 213: 2225681-213.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
1.13 KB
11.34 KB

From #211
1. Yes, it does need to be a constant. It is the property name being migrated and it doesn't change.
2. That is true but this also needs the Block::prepareRow() which uses properties which are setup in Block::query().
3. Yes, fixed as suggested.

Status: Needs review » Needs work

The last submitted patch, 215: 2225681-215.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

jofitz’s picture

Status: Needs work » Needs review
FileSize
636 bytes
11.23 KB

Remove redundant use statement.

Status: Needs review » Needs work

The last submitted patch, 217: 2225681-217.patch, failed testing. View results

maxocub’s picture

Status: Needs work » Reviewed & tested by the community

@quietone, re #215: Thanks for the explanation. I think this is ready now.

quietone’s picture

@Jo Fitzgerald, thanks for cleaning up my mistakes.

quietone’s picture

Status: Reviewed & tested by the community » Needs review

Sorry, I think this needs a pause and a double check that the source plugins and migrations are in the desired directory. This has a different structure than the menu links translation it needs to be double checked.

heddn’s picture

Assigned: Unassigned » quietone

Assigning to quietone to review.

quietone’s picture

Assigned: quietone » Unassigned
FileSize
11.1 KB
1.97 KB

Like the other i18n migration, move files to block module, except for the migration.

Status: Needs review » Needs work

The last submitted patch, 223: 2225681-223.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
640 bytes
11.08 KB

Namespace error

quietone’s picture

The review here is to confirm that the migration files are in the correct directory. Only the migration is to be content_translation and the related file in block. This is to follow the pattern of #2225587: Migrate D6 i18n menu links.

maxocub’s picture

Status: Needs review » Reviewed & tested by the community

The new patch only differs from last RTBC by classes moved from Content Translation to Block. I agree with this choice, so back to RTBC.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 225: 2225681-225.patch, failed testing. View results

maxocub’s picture

Issue tags: +Needs reroll

Needs a re-roll, again.

quietone’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll

Retested the latest patch, #225 and passed. No reroll need probably because #2886609: Migrate translations for D6 i18n taxonomy 'localized' terms was reverted. Therefore, restoring RTBC.

quietone’s picture

Status: Needs review » Reviewed & tested by the community

I mean RTBC nor NR

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/block/src/Plugin/migrate/source/d6/BlockTranslation.php
    @@ -0,0 +1,54 @@
    +    // Let the parent set the block table to use, but do not use the parent
    +    // query. Instead build a query so can use a left join to the selected block
    +    // table.
    +    parent::query();
    +    $query = $this->select('i18n_blocks', 'i18n')
    +      ->fields('i18n', ['ibid', 'module', 'delta', 'type', 'language'])
    +      ->fields('b', ['bid', 'theme', 'title']);
    +    $query->addField('b', 'module', 'block_module');
    +    $query->addField('b', 'delta', 'block_delta');
    +    $query->innerJoin($this->blockTable, 'b', ('b.module = i18n.module AND b.delta = i18n.delta'));
    +    return $query;
    

    We say left join but we do an inner. What's the point of doing the block_module and block_delta when we know these are equal to the values from i18n_blocks?

  2. +++ b/core/modules/block/src/Plugin/migrate/source/d6/BlockTranslation.php
    @@ -0,0 +1,54 @@
    +    $fields = parent::fields();
    +    $fields['language'] = $this->t('Language for this field.');
    +    return $fields;
    

    We also have 'type', 'ibid', 'block_module' and 'block_delta'.

    And the parent::fields() also returns

          'weight' => $this->t('Weight of the block for ordering within regions.'),
          'region' => $this->t('Region the block is placed in.'),
          'visibility' => $this->t('Visibility expression.'),
          'pages' => $this->t('Pages list.'),
          'cache' => $this->t('Cache rule.'),
    

    Should the query also return the missing fields from the block table?

quietone’s picture

Assigned: Unassigned » quietone

Will do this soon

quietone’s picture

1. Corrected the comment and reworked the query.
2. fields() no longer uses fields from the parent and 'type' and 'ibid' have been added. Also, added a prepareRow that does only what is needed, adding the default_theme to the row, which is not in fields() only because I see that the parent does not include it.

quietone’s picture

Assigned: quietone » Unassigned

Un-assigning so someone can review

masipila’s picture

I review the latest patch that addresses @alexpott's feedback in #232.

Only one question: We add default_theme in the prepareRow() method. Should we include this source property in fields()?

Otherwise this looks good to me. Leaving to NR for the question above. Once that is clarified, this looks ready.

Markus

quietone’s picture

I wasn't sure about default_theme. As I said in #234.2 it isn't added in the parent and even though this no longer uses the parent::prepareRow() I don't know why it wasn't included and didn't want to change it arbitrarily. I mean if we change it here it should be changed in the parent:fields() as well.

masipila’s picture

Status: Needs review » Needs work

I believe we should add the properties that we set in prepareRow() to fields().

We are doing it for example in #2975509: Migrate D6 vocabulary language settings so for the sake of consistency, we should do it here as well.

quietone’s picture

Thanks masipila. Added default_theme to fields() and updated the source plugin test to also test that property. Add added a space for coding standards.

masipila’s picture

Issue summary: View changes

This was RTBC in #227. All feedback since that has been addressed.

I updated the Issue Summary to help committers to review this. I also queued this to PostgreSQL anf SQLite tests once more. Once they pass, this is ready.

Markus

masipila’s picture

Status: Needs review » Reviewed & tested by the community

And the tests are green. RTBC.

Gábor Hojtsy’s picture

  • Gábor Hojtsy committed 9319cfd on 8.6.x
    Issue #2225681 by quietone, Jo Fitzgerald, dipakmdhrm, Adita, RytoEX,...
Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Wow, quite some work in this since I last comitted it in November 2017. And it looked like just a directory rename :) Thanks all for continued work on this.

Committed 9319cfd and pushed to 8.6.x.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.