Commit 876073f1 authored by catch's avatar catch
Browse files

Issue #3143676 by quietone, herved, ayushmishra206, Meenakshi.g,...

Issue #3143676 by quietone, herved, ayushmishra206, Meenakshi.g, ridhimaabrol24, mikelutz, shaktik: Missing condition in d7_term_localized_translation source plugin causing invalid migration
parent 1bfea454
Loading
Loading
Loading
Loading
+61 −0
Original line number Diff line number Diff line
@@ -19707,6 +19707,26 @@
  'objectindex' => '0',
  'format' => '',
))
->values(array(
  'lid' => '797',
  'textgroup' => 'taxonomy',
  'context' => 'term:25:name',
  'objectid' => '25',
  'type' => 'term',
  'property' => 'name',
  'objectindex' => '25',
  'format' => '',
))
->values(array(
  'lid' => '798',
  'textgroup' => 'taxonomy',
  'context' => 'term:25:description',
  'objectid' => '25',
  'type' => 'term',
  'property' => 'description',
  'objectindex' => '25',
  'format' => '',
))
->execute();
$connection->schema()->createTable('i18n_translation_set', array(
  'fields' => array(
@@ -21315,6 +21335,22 @@
  'plural' => '0',
  'i18n_status' => '0',
))
->values(array(
  'lid' => '797',
  'translation' => 'fr - Emissary',
  'language' => 'fr',
  'plid' => '0',
  'plural' => '0',
  'i18n_status' => '0',
))
->values(array(
  'lid' => '798',
  'translation' => 'fr - Pilot episode',
  'language' => 'fr',
  'plid' => '0',
  'plural' => '0',
  'i18n_status' => '0',
))
->execute();
$connection->schema()->createTable('menu_custom', array(
  'fields' => array(
@@ -56789,6 +56825,16 @@
  'language' => 'fr',
  'i18n_tsid' => '0',
))
->values(array(
  'tid' => '25',
  'vid' => '8',
  'name' => 'Emissary',
  'description' => 'Pilot episode',
  'format' => 'filtered_html',
  'weight' => '0',
  'language' => 'und',
  'i18n_tsid' => '0',
))
->execute();
$connection->schema()->createTable('taxonomy_term_hierarchy', array(
  'fields' => array(
@@ -56915,6 +56961,10 @@
  'tid' => '8',
  'parent' => '6',
))
->values(array(
  'tid' => '25',
  'parent' => '0',
))
->execute();
$connection->schema()->createTable('taxonomy_vocabulary', array(
  'fields' => array(
@@ -57069,6 +57119,17 @@
  'language' => 'fr',
  'i18n_mode' => '2',
))
->values(array(
  'vid' => '8',
  'name' => 'VocabLocalized2',
  'machine_name' => 'vocablocalized2',
  'description' => '',
  'hierarchy' => '0',
  'module' => 'taxonomy',
  'weight' => '0',
  'language' => 'und',
  'i18n_mode' => '1',
))
->execute();
$connection->schema()->createTable('tracker_node', array(
  'fields' => array(
+4 −4
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ protected function getEntityCounts() {
      'file' => 3,
      'filter_format' => 7,
      'image_style' => 7,
      'language_content_settings' => 21,
      'language_content_settings' => 22,
      'node' => 7,
      'node_type' => 7,
      'rdf_mapping' => 8,
@@ -99,8 +99,8 @@ protected function getEntityCounts() {
      'shortcut_set' => 2,
      'action' => 19,
      'menu' => 7,
      'taxonomy_term' => 24,
      'taxonomy_vocabulary' => 7,
      'taxonomy_term' => 25,
      'taxonomy_vocabulary' => 8,
      'path_alias' => 8,
      'tour' => 6,
      'user' => 4,
@@ -126,7 +126,7 @@ protected function getEntityCountsIncremental() {
    $counts['file'] = 4;
    $counts['menu_link_content'] = 13;
    $counts['node'] = 8;
    $counts['taxonomy_term'] = 25;
    $counts['taxonomy_term'] = 26;
    $counts['user'] = 5;
    return $counts;
  }
+7 −23
Original line number Diff line number Diff line
@@ -50,38 +50,22 @@ public function query() {
   * {@inheritdoc}
   */
  public function prepareRow(Row $row) {
    parent::prepareRow($row);

    // Override language with ltlanguage.
    $language = $row->getSourceProperty('ltlanguage');
    $tid = $row->getSourceProperty('tid');
    $row->setSourceProperty('language', $language);

    // If this row has been migrated it is a duplicate then skip it.
    if ($this->idMap->lookupDestinationIds(['tid' => $tid, 'language' => $language])) {
      return FALSE;
    }
    // Set the i18n string table for use in I18nQueryTrait.
    $this->i18nStringTable = 'i18n_string';

    // Save the translation for the property already in the row.
    $property_in_row = $row->getSourceProperty('property');
    $row->setSourceProperty($property_in_row . '_translated', $row->getSourceProperty('translation'));

    // Get the translation for the property not already in the row and save it
    // in the row.
    $property_not_in_row = ($property_in_row == 'name') ? 'description' : 'name';

    // Get the translation, if one exists, for the property not already in the
    // row.
    $query = $this->select('i18n_string', 'i18n')
      ->fields('i18n', ['lid'])
      ->condition('i18n.property', $property_not_in_row);
    $query->leftJoin('locales_target', 'lt', 'i18n.lid = lt.lid');
    $query->condition('lt.language', $language);
    $query->addField('lt', 'translation');
    $results = $query->execute()->fetchAssoc();
    if (!$results) {
      $row->setSourceProperty($property_not_in_row . '_translated', NULL);
    }
    else {
      $row->setSourceProperty($property_not_in_row . '_translated', $results['translation']);
    }
    parent::prepareRow($row);
    return $this->getPropertyNotInRowTranslation($row, $property_not_in_row, 'tid', $this->idMap);
  }

  /**
+2 −1
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@ public function testTaxonomyTerms() {

    // Reset the forums tree data so this new term is included in the tree.
    unset($this->treeData['forums']);
    $this->assertEntity(25, 'en', 'Forum Container', 'forums', '', '', 0, [], NULL, NULL, 1);
    $this->assertEntity(26, 'en', 'Forum Container', 'forums', '', '', 0, [], NULL, NULL, 1);

    // Test taxonomy term language translations.
    $this->assertEntity(19, 'en', 'Jupiter Station', 'vocablocalized', 'Holographic research.', 'filtered_html', 0, [], NULL, NULL, 1);
@@ -139,6 +139,7 @@ public function testTaxonomyTerms() {
    // Localized.
    $this->assertEntity(19, 'en', 'Jupiter Station', 'vocablocalized', 'Holographic research.', 'filtered_html', '0', []);
    $this->assertEntity(20, 'en', 'DS9', 'vocablocalized', 'Terok Nor', 'filtered_html', '0', []);
    $this->assertEntity(25, 'en', 'Emissary', 'vocablocalized2', 'Pilot episode', 'filtered_html', '0', []);

    /** @var \Drupal\taxonomy\TermInterface $entity */
    $entity = Term::load(20);
+8 −0
Original line number Diff line number Diff line
@@ -112,6 +112,7 @@ protected function assertHierarchy($vid, $tid, array $parent_ids) {
  public function testTranslatedLocalizedTaxonomyTerms() {
    $this->assertEntity(19, 'en', 'Jupiter Station', 'vocablocalized', 'Holographic research.', 'filtered_html', '0', []);
    $this->assertEntity(20, 'en', 'DS9', 'vocablocalized', 'Terok Nor', 'filtered_html', '0', []);
    $this->assertEntity(25, 'en', 'Emissary', 'vocablocalized2', 'Pilot episode', 'filtered_html', '0', []);

    /** @var \Drupal\taxonomy\TermInterface $entity */
    $entity = Term::load(19);
@@ -128,6 +129,13 @@ public function testTranslatedLocalizedTaxonomyTerms() {
    $this->assertSame('fr - DS9 (localized)', $translation->label());
    $this->assertSame('fr - Terok Nor (localized)', $translation->getDescription());
    $this->assertFALSE($entity->hasTranslation('is'));

    $entity = Term::load(25);
    $this->assertFalse($entity->hasTranslation('is'));
    $this->assertTrue($entity->hasTranslation('fr'));
    $translation = $entity->getTranslation('fr');
    $this->assertSame('fr - Emissary', $translation->label());
    $this->assertSame('fr - Pilot episode', $translation->getDescription());
  }

}
Loading