diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/entity_reference/selection/TermSelection.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/entity_reference/selection/TermSelection.php index e9f5f2f..df87767 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/entity_reference/selection/TermSelection.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/entity_reference/selection/TermSelection.php @@ -30,26 +30,7 @@ class TermSelection extends SelectionBase { * Overrides SelectionBase::entityQueryAlter(). */ public function entityQueryAlter(SelectInterface $query) { - // The Taxonomy module doesn't implement any proper taxonomy term access, - // and as a consequence doesn't make sure that taxonomy terms cannot be - // viewed when the user doesn't have access to the vocabulary. - $tables = $query->getTables(); - $base_table = $tables['base_table']['alias']; - $vocabulary_alias = $query->innerJoin('taxonomy_vocabulary', 'n', '%alias.vid = ' . $base_table . '.vid'); - $query->addMetadata('base_table', $vocabulary_alias); - // Pass the query to the taxonomy access control. - $this->reAlterQuery($query, 'taxonomy_vocabulary_access', $vocabulary_alias); - - // Also, the taxonomy term entity exposes a bundle, but doesn't have a - // bundle column in the database. We have to alter the query ourselves to go - // fetch the bundle. - $conditions = &$query->conditions(); - foreach ($conditions as $key => &$condition) { - if ($key !== '#conjunction' && is_string($condition['field']) && $condition['field'] === 'vocabulary_machine_name') { - $condition['field'] = $vocabulary_alias . '.machine_name'; - break; - } - } + // @todo: How to set access, as vocabulary is now config? } /** @@ -62,15 +43,14 @@ public function getReferencableEntities($match = NULL, $match_operator = 'CONTAI $options = array(); - // We imitate core by calling taxonomy_get_tree(). $entity_info = entity_get_info('taxonomy_term'); $bundles = !empty($this->instance['settings']['handler_settings']['target_bundles']) ? $this->instance['settings']['handler_settings']['target_bundles'] : array_keys($entity_info['bundles']); foreach ($bundles as $bundle) { - if ($vocabulary = taxonomy_vocabulary_machine_name_load($bundle)) { - if ($terms = taxonomy_get_tree($vocabulary->vid, 0)) { + if ($vocabulary = entity_load('taxonomy_vocabulary',$bundle)) { + if ($terms = taxonomy_get_tree($vocabulary->id(), 0)) { foreach ($terms as $term) { - $options[$vocabulary->machine_name][$term->tid] = str_repeat('-', $term->depth) . check_plain($term->name); + $options[$vocabulary->id()][$term->tid] = str_repeat('-', $term->depth) . check_plain($term->name); } } }