diff --git a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php index 1e9f664be4..a841774200 100644 --- a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php @@ -6,7 +6,6 @@ use Drupal\Core\Entity\EntityRepositoryInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; -use Drupal\taxonomy\Entity\Term; use Drupal\taxonomy\TermInterface; use Drupal\taxonomy\TermStorageInterface; use Drupal\taxonomy\VocabularyInterface; @@ -220,7 +219,11 @@ protected function valueForm(&$form, FormStateInterface $form_state) { if (!empty($this->options['hierarchy']) && $this->options['limit']) { $terms = []; foreach ($vocabularies as $vocabulary) { - $terms = array_merge($terms, $this->termStorage->loadTree($vocabulary->id(), 0, NULL, TRUE)); + $terms = array_merge($terms, array_filter( + $this->termStorage->loadTree($vocabulary->id(), 0, NULL, TRUE), function (TermInterface $term): bool { + return $term->isPublished() || $this->currentUser->hasPermission('administer taxonomy'); + } + )); } } else { @@ -402,7 +405,7 @@ public function adminSummary() { if ($this->value) { $this->value = array_filter($this->value); - $terms = Term::loadMultiple($this->value); + $terms = $this->termStorage->loadMultiple($this->value); foreach ($terms as $term) { $this->valueOptions[$term->id()] = $this->entityRepository ->getTranslationFromContext($term)