Skip to content
Snippets Groups Projects
Verified Commit 3f7861f8 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

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
parent fc78db52
No related branches found
No related tags found
8 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!144Issue #2666286: Clean up menu_ui to conform to Drupal coding standards,!16Draft: Resolve #2081585 "History storage",!13Resolve #2903456
......@@ -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];
}
......
......@@ -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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment