diff --git a/core/modules/language/src/Plugin/migrate/source/d6/LanguageContentSettingsTaxonomyVocabulary.php b/core/modules/language/src/Plugin/migrate/source/d6/LanguageContentSettingsTaxonomyVocabulary.php index 4cde5687f6a4a984bddc803ffd0b2f5829c12f69..7787865b61ba1dfd1ea1adfac6ac3e6fadd0f928 100644 --- a/core/modules/language/src/Plugin/migrate/source/d6/LanguageContentSettingsTaxonomyVocabulary.php +++ b/core/modules/language/src/Plugin/migrate/source/d6/LanguageContentSettingsTaxonomyVocabulary.php @@ -19,8 +19,14 @@ class LanguageContentSettingsTaxonomyVocabulary extends DrupalSqlBase { * {@inheritdoc} */ public function query() { - return $this->select('vocabulary', 'v') - ->fields('v', ['vid', 'language']); + $query = $this->select('vocabulary', 'v') + ->fields('v', ['vid']); + if ($this->getDatabase() + ->schema() + ->fieldExists('vocabulary', 'language')) { + $query->addField('v', 'language'); + } + return $query; } /** @@ -44,9 +50,9 @@ public function prepareRow(Row $row) { // 2 - Predefined language for a vocabulary and its terms. // 3 - Per-language terms, translatable (referencing terms with different // languages) but not localizable. - $i18ntaxonomy_vocabulary = $this->variableGet('i18ntaxonomy_vocabulary', NULL); + $i18ntaxonomy_vocabulary = $this->variableGet('i18ntaxonomy_vocabulary', []); $vid = $row->getSourceProperty('vid'); - $state = FALSE; + $state = 0; if (array_key_exists($vid, $i18ntaxonomy_vocabulary)) { $state = $i18ntaxonomy_vocabulary[$vid]; } diff --git a/core/modules/language/tests/src/Kernel/Plugin/migrate/source/d6/LanguageContentTaxonomyVocabularySettingsTest.php b/core/modules/language/tests/src/Kernel/Plugin/migrate/source/d6/LanguageContentTaxonomyVocabularySettingsTest.php index c709859f764e42438153ebcc974ba40a2b40e4a7..e4abb3d9fe68ea41197c8156b0a4ca7b9d42cd75 100644 --- a/core/modules/language/tests/src/Kernel/Plugin/migrate/source/d6/LanguageContentTaxonomyVocabularySettingsTest.php +++ b/core/modules/language/tests/src/Kernel/Plugin/migrate/source/d6/LanguageContentTaxonomyVocabularySettingsTest.php @@ -75,7 +75,33 @@ public function providerSource() { ], ]; + // Test without a language column in the database. + $tests[1] = $tests[0]; + foreach ($tests[1]['source_data']['vocabulary'] as $key => $row) { + unset($tests[1]['source_data']['vocabulary'][$key]['language']); + } + $tests[1]['source_data']['variable'] = [ + [ + 'name' => 'i18ntaxonomy_vocabulary', + 'value' => 'a:4:{i:1;s:1:"0";i:2;s:1:"0";i:3;s:1:"3";i:5;s:1:"1";}', + ], + ]; + $tests[1]['expected_data'] = [ + [ + 'vid' => 1, + 'state' => 0, + ], + [ + 'vid' => 2, + 'state' => 0, + ], + ]; + + // Test without a i18ntaxonomy_vocabulary variable. + $tests[2] = $tests[1]; + unset($tests[2]['source_data']['variable']); return $tests; + } }