Unverified Commit c3e6adec authored by larowlan's avatar larowlan

Issue #3101045 by quietone, mikelutz, Stefan Kangas, NiklasBr:...

Issue #3101045 by quietone, mikelutz, Stefan Kangas, NiklasBr: LanguageContentSettingsTaxonomyVocabulary source plugin should only add language column if it exists

(cherry picked from commit 3f7861f8)
parent cfd66d18
...@@ -19,8 +19,14 @@ class LanguageContentSettingsTaxonomyVocabulary extends DrupalSqlBase { ...@@ -19,8 +19,14 @@ class LanguageContentSettingsTaxonomyVocabulary extends DrupalSqlBase {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function query() { public function query() {
return $this->select('vocabulary', 'v') $query = $this->select('vocabulary', 'v')
->fields('v', ['vid', 'language']); ->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) { ...@@ -44,9 +50,9 @@ public function prepareRow(Row $row) {
// 2 - Predefined language for a vocabulary and its terms. // 2 - Predefined language for a vocabulary and its terms.
// 3 - Per-language terms, translatable (referencing terms with different // 3 - Per-language terms, translatable (referencing terms with different
// languages) but not localizable. // languages) but not localizable.
$i18ntaxonomy_vocabulary = $this->variableGet('i18ntaxonomy_vocabulary', NULL); $i18ntaxonomy_vocabulary = $this->variableGet('i18ntaxonomy_vocabulary', []);
$vid = $row->getSourceProperty('vid'); $vid = $row->getSourceProperty('vid');
$state = FALSE; $state = 0;
if (array_key_exists($vid, $i18ntaxonomy_vocabulary)) { if (array_key_exists($vid, $i18ntaxonomy_vocabulary)) {
$state = $i18ntaxonomy_vocabulary[$vid]; $state = $i18ntaxonomy_vocabulary[$vid];
} }
......
...@@ -75,7 +75,33 @@ public function providerSource() { ...@@ -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; return $tests;
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment