diff --git a/core/modules/taxonomy/src/Entity/Term.php b/core/modules/taxonomy/src/Entity/Term.php index 435cbe6..852fa4b 100644 --- a/core/modules/taxonomy/src/Entity/Term.php +++ b/core/modules/taxonomy/src/Entity/Term.php @@ -34,6 +34,7 @@ * "translation" = "Drupal\taxonomy\TermTranslationHandler" * }, * base_table = "taxonomy_term_data", + * data_table = "taxonomy_term_field_data", * uri_callback = "taxonomy_term_uri", * fieldable = TRUE, * translatable = TRUE, @@ -125,6 +126,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['name'] = FieldDefinition::create('string') ->setLabel(t('Name')) ->setDescription(t('The term name.')) + ->setTranslatable(TRUE) ->setRequired(TRUE) ->setSetting('max_length', 255) ->setDisplayOptions('view', array( @@ -141,6 +143,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['description'] = FieldDefinition::create('text_long') ->setLabel(t('Description')) ->setDescription(t('A description of the term.')) + ->setTranslatable(TRUE) ->setSetting('text_processing', 1) ->setDisplayOptions('view', array( 'label' => 'hidden', diff --git a/core/modules/taxonomy/src/Plugin/views/argument/IndexTid.php b/core/modules/taxonomy/src/Plugin/views/argument/IndexTid.php index 59b4332..a6f734c 100644 --- a/core/modules/taxonomy/src/Plugin/views/argument/IndexTid.php +++ b/core/modules/taxonomy/src/Plugin/views/argument/IndexTid.php @@ -21,9 +21,10 @@ class IndexTid extends ManyToOne { public function titleQuery() { $titles = array(); - $result = db_select('taxonomy_term_data', 'td') + $result = db_select('taxonomy_term_field_data', 'td') ->fields('td', array('name')) ->condition('td.tid', $this->value) + ->condition('td.default_langcode', 1) ->execute(); foreach ($result as $term_record) { $titles[] = String::checkPlain($term_record->name); diff --git a/core/modules/taxonomy/src/Plugin/views/field/Language.php b/core/modules/taxonomy/src/Plugin/views/field/Language.php index 13e3d23..f95f492 100644 --- a/core/modules/taxonomy/src/Plugin/views/field/Language.php +++ b/core/modules/taxonomy/src/Plugin/views/field/Language.php @@ -21,7 +21,7 @@ class Language extends Taxonomy { */ public function render(ResultRow $values) { $value = $this->getValue($values); - $language = language_load($value); + $language = \Drupal::languageManager()->getLanguage($value); $value = $language ? $language->name : ''; return $this->renderLink($this->sanitizeValue($value), $values); diff --git a/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php b/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php index 90e8225..77018ce 100644 --- a/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php +++ b/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php @@ -102,13 +102,14 @@ public function preRender(&$values) { } if ($nids) { - $query = db_select('taxonomy_term_data', 'td'); + $query = db_select('taxonomy_term_field_data', 'td'); $query->innerJoin('taxonomy_index', 'tn', 'td.tid = tn.tid'); $query->fields('td'); $query->addField('tn', 'nid', 'node_nid'); $query->orderby('td.weight'); $query->orderby('td.name'); $query->condition('tn.nid', $nids); + $query->condition('td.default_langcode', 1); $query->addTag('term_access'); $vocabs = array_filter($this->options['vids']); if (!empty($this->options['limit']) && !empty($vocabs)) { diff --git a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php index 2c708ea..39819fc 100644 --- a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php @@ -107,9 +107,10 @@ protected function valueForm(&$form, &$form_state) { if ($this->options['type'] == 'textfield') { $default = ''; if ($this->value) { - $result = db_select('taxonomy_term_data', 'td') + $result = db_select('taxonomy_term_field_data', 'td') ->fields('td') ->condition('td.tid', $this->value) + ->condition('td.default_langcode', 1) ->execute(); foreach ($result as $term_record) { if ($default) { @@ -145,7 +146,7 @@ protected function valueForm(&$form, &$form_state) { } else { $options = array(); - $query = db_select('taxonomy_term_data', 'td'); + $query = db_select('taxonomy_term_field_data', 'td'); $query->fields('td'); // @todo Sorting on vocabulary properties http://drupal.org/node/1821274 $query->orderby('td.weight'); @@ -154,6 +155,7 @@ protected function valueForm(&$form, &$form_state) { if ($this->options['limit']) { $query->condition('td.vid', $vocabulary->id()); } + $query->condition('td.default_langcode', 1); $result = $query->execute(); foreach ($result as $term_record) { $options[$term_record->tid] = $term_record->name; @@ -310,10 +312,11 @@ function validate_term_strings(&$form, $values) { return FALSE; } - $query = db_select('taxonomy_term_data', 'td'); + $query = db_select('taxonomy_term_field_data', 'td'); $query->fields('td'); $query->condition('td.name', $names); $query->condition('td.vid', $this->options['vid']); + $query->condition('td.default_langcode', 1); $query->addTag('term_access'); $result = $query->execute(); foreach ($result as $term_record) { @@ -353,9 +356,10 @@ public function adminSummary() { if ($this->value) { $this->value = array_filter($this->value); - $result = db_select('taxonomy_term_data', 'td') + $result = db_select('taxonomy_term_field_data', 'td') ->fields('td') ->condition('td.tid', $this->value) + ->condition('td.default_langcode', 1) ->execute(); foreach ($result as $term_record) { $this->value_options[$term_record->tid] = $term_record->name; diff --git a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php index da0a61d..a0f3857 100644 --- a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php @@ -50,7 +50,7 @@ public function query() { return; } elseif (count($this->value) == 1) { - // Somethis $this->value is an array with a single element so convert it. + // Sometimes $this->value is an array with a single element so convert it. if (is_array($this->value)) { $this->value = current($this->value); } diff --git a/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php b/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php index c720ee9..c32ff95 100644 --- a/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php +++ b/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php @@ -68,7 +68,7 @@ public function query() { $this->ensureMyTable(); $def = $this->definition; - $def['table'] = 'taxonomy_term_data'; + $def['table'] = 'taxonomy_term_field_data'; if (!array_filter($this->options['vids'])) { $taxonomy_index = $this->query->addTable('taxonomy_index', $this->relationship); @@ -85,9 +85,10 @@ public function query() { $def['type'] = empty($this->options['required']) ? 'LEFT' : 'INNER'; $def['adjusted'] = TRUE; - $query = db_select('taxonomy_term_data', 'td'); + $query = db_select('taxonomy_term_field_data', 'td'); $query->addJoin($def['type'], 'taxonomy_index', 'tn', 'tn.tid = td.tid'); $query->condition('td.vid', array_filter($this->options['vids'])); + $query->condition('td.default_langcode', 1); $query->addTag('term_access'); $query->fields('td'); $query->fields('tn', array('nid')); @@ -99,7 +100,7 @@ public function query() { // use a short alias for this: $alias = $def['table'] . '_' . $this->table; - $this->alias = $this->query->addRelationship($alias, $join, 'taxonomy_term_data', $this->relationship); + $this->alias = $this->query->addRelationship($alias, $join, 'taxonomy_term_field_data', $this->relationship); } } diff --git a/core/modules/taxonomy/src/Plugin/views/wizard/TaxonomyTerm.php b/core/modules/taxonomy/src/Plugin/views/wizard/TaxonomyTerm.php index 1c34511..480dc26 100644 --- a/core/modules/taxonomy/src/Plugin/views/wizard/TaxonomyTerm.php +++ b/core/modules/taxonomy/src/Plugin/views/wizard/TaxonomyTerm.php @@ -49,7 +49,7 @@ protected function defaultDisplayOptions() { /* Field: Taxonomy: Term */ $display_options['fields']['name']['id'] = 'name'; - $display_options['fields']['name']['table'] = 'taxonomy_term_data'; + $display_options['fields']['name']['table'] = 'taxonomy_term_field_data'; $display_options['fields']['name']['field'] = 'name'; $display_options['fields']['name']['provider'] = 'taxonomy'; $display_options['fields']['name']['label'] = ''; diff --git a/core/modules/taxonomy/src/TermStorage.php b/core/modules/taxonomy/src/TermStorage.php index 381b0ab..e0908ae 100644 --- a/core/modules/taxonomy/src/TermStorage.php +++ b/core/modules/taxonomy/src/TermStorage.php @@ -87,10 +87,11 @@ public function updateTermHierarchy(EntityInterface $term) { * {@inheritdoc} */ public function loadParents($tid) { - $query = $this->database->select('taxonomy_term_data', 't'); + $query = $this->database->select('taxonomy_term_field_data', 't'); $query->join('taxonomy_term_hierarchy', 'h', 'h.parent = t.tid'); $query->addField('t', 'tid'); $query->condition('h.tid', $tid); + $query->condition('t.default_langcode', 1); $query->addTag('term_access'); $query->orderBy('t.weight'); $query->orderBy('t.name'); @@ -101,13 +102,14 @@ public function loadParents($tid) { * {@inheritdoc} */ public function loadChildren($tid, $vid = NULL) { - $query = $this->database->select('taxonomy_term_data', 't'); + $query = $this->database->select('taxonomy_term_field_data', 't'); $query->join('taxonomy_term_hierarchy', 'h', 'h.tid = t.tid'); $query->addField('t', 'tid'); $query->condition('h.parent', $tid); if ($vid) { $query->condition('t.vid', $vid); } + $query->condition('t.default_langcode', 1); $query->addTag('term_access'); $query->orderBy('t.weight'); $query->orderBy('t.name'); @@ -118,13 +120,14 @@ public function loadChildren($tid, $vid = NULL) { * {@inheritdoc} */ public function loadTree($vid) { - $query = $this->database->select('taxonomy_term_data', 't'); + $query = $this->database->select('taxonomy_term_field_data', 't'); $query->join('taxonomy_term_hierarchy', 'h', 'h.tid = t.tid'); return $query ->addTag('term_access') ->fields('t') ->fields('h', array('parent')) ->condition('t.vid', $vid) + ->condition('t.default_langcode', 1) ->orderBy('t.weight') ->orderBy('t.name') ->execute(); @@ -146,7 +149,7 @@ public function nodeCount($vid) { * {@inheritdoc} */ public function resetWeights($vid) { - $this->database->update('taxonomy_term_data') + $this->database->update('taxonomy_term_field_data') ->fields(array('weight' => 0)) ->condition('vid', $vid) ->execute(); @@ -160,12 +163,12 @@ public function getSchema() { // Marking the respective fields as NOT NULL makes the indexes more // performant. - $schema['taxonomy_term_data']['fields']['weight']['not null'] = TRUE; - $schema['taxonomy_term_data']['fields']['name']['not null'] = TRUE; + $schema['taxonomy_term_field_data']['fields']['weight']['not null'] = TRUE; + $schema['taxonomy_term_field_data']['fields']['name']['not null'] = TRUE; unset($schema['taxonomy_term_data']['indexes']['field__vid']); unset($schema['taxonomy_term_data']['indexes']['field__description__format']); - $schema['taxonomy_term_data']['indexes'] += array( + $schema['taxonomy_term_field_data']['indexes'] += array( 'taxonomy_term__tree' => array('vid', 'weight', 'name'), 'taxonomy_term__vid_name' => array('vid', 'name'), 'taxonomy_term__name' => array('name'),