diff --git a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php index 2d0eb83..8ebc909 100644 --- a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php @@ -391,8 +391,7 @@ public function calculateDependencies() { $vocabulary = $this->vocabularyStorage->load($this->options['vid']); $dependencies[$vocabulary->getConfigDependencyKey()][] = $vocabulary->getConfigDependencyName(); - foreach ($this->options['value'] as $tid) { - $term = $this->termStorage->load($tid); + foreach ($this->termStorage->loadMultiple($this->options['value']) as $term) { $dependencies[$term->getConfigDependencyKey()][] = $term->getConfigDependencyName(); } diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidFilterTest.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidFilterTest.php new file mode 100644 index 0000000..72de537 --- /dev/null +++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidFilterTest.php @@ -0,0 +1,97 @@ + 'tags', + 'name' => 'Tags', + ])->save(); + + $term = Term::create([ + 'vid' => 'tags', + 'name' => 'muh', + ]); + $term->save(); + $this->terms[$term->id()] = $term; + $term = Term::create([ + 'vid' => 'tags', + 'name' => 'muh', + ]); + $term->save(); + $this->terms[$term->id()] = $term; + + ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views')); + } + + public function testConfigDependency() { + /** @var \Drupal\views\Entity\View $view */ + $view = View::load('test_filter_taxonomy_index_tid__non_existing_dependency'); + + $view->calculateDependencies(); + $this->assertEqual([ + 'config' => [ + 'taxonomy.vocabulary.tags', + ], + 'content' => [ + $this->terms[3]->getConfigDependencyName(), + ], + 'module' => [ + 'node', + 'taxonomy', + 'user', + ], + ], $view->getDependencies()); + + $this->terms[3]->delete(); + + $view->calculateDependencies(); + + $this->assertEqual([ + 'config' => [ + 'taxonomy.vocabulary.tags', + ], + 'module' => [ + 'node', + 'taxonomy', + 'user', + ], + ], $view->getDependencies()); + } + +} diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php index 5e40666..dc57559 100644 --- a/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php +++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php @@ -55,11 +55,13 @@ /** * {@inheritdoc} */ - protected function setUp() { - parent::setUp(); + protected function setUp($import_test_views = TRUE) { + parent::setUp($import_test_views); $this->mockStandardInstall(); - ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views')); + if ($import_test_views) { + ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views')); + } $this->term1 = $this->createTerm(); $this->term2 = $this->createTerm(); diff --git a/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_filter_taxonomy_index_tid__non_existing_dependency.yml b/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_filter_taxonomy_index_tid__non_existing_dependency.yml new file mode 100644 index 0000000..8afc274 --- /dev/null +++ b/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_filter_taxonomy_index_tid__non_existing_dependency.yml @@ -0,0 +1,186 @@ +langcode: en +status: true +dependencies: + module: + - node + - taxonomy + - user +id: test_filter_taxonomy_index_tid__non_existing_dependency +label: test_filter_taxonomy_index_tid__non_existing_dependency +module: views +description: '' +tag: '' +base_table: node_field_data +base_field: nid +core: 8.x +display: + default: + display_plugin: default + id: default + display_title: Master + position: 1 + display_options: + access: + type: perm + options: + perm: 'access content' + cache: + type: tag + options: { } + query: + type: views_query + options: + disable_sql_rewrite: false + distinct: false + replica: false + query_comment: '' + query_tags: { } + exposed_form: + type: basic + options: + submit_button: Apply + reset_button: false + reset_button_label: Reset + exposed_sorts_label: 'Sort by' + expose_sort_order: true + sort_asc_label: Asc + sort_desc_label: Desc + pager: + type: full + options: + items_per_page: 10 + offset: 0 + id: 0 + total_pages: null + expose: + items_per_page: false + items_per_page_label: 'Items per page' + items_per_page_options: '5, 10, 25, 50' + items_per_page_options_all: false + items_per_page_options_all_label: '- All -' + offset: false + offset_label: Offset + tags: + previous: '‹ Previous' + next: 'Next ›' + first: '« First' + last: 'Last »' + quantity: 9 + style: + type: default + options: + grouping: { } + row_class: '' + default_row_class: true + uses_fields: false + row: + type: fields + options: + inline: { } + separator: '' + hide_empty: false + default_field_elements: true + fields: + title: + id: title + table: node_field_data + field: title + label: '' + alter: + alter_text: false + make_link: false + absolute: false + trim: false + word_boundary: false + ellipsis: false + strip_tags: false + html: false + hide_empty: false + empty_zero: false + relationship: none + group_type: group + admin_label: '' + exclude: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: true + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_alter_empty: true + plugin_id: field + entity_type: node + entity_field: title + filters: + status: + value: true + table: node_field_data + field: status + id: status + expose: + operator: '0' + group: 1 + plugin_id: boolean + entity_type: node + entity_field: status + tid: + id: tid + table: taxonomy_index + field: tid + relationship: none + group_type: group + admin_label: '' + operator: or + value: + - 3 + group: 1 + exposed: false + expose: + operator_id: '0' + label: '' + description: '' + use_operator: false + operator: '' + identifier: '' + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + reduce: false + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + reduce_duplicates: false + type: select + limit: true + vid: tags + hierarchy: true + error_message: true + plugin_id: taxonomy_index_tid + sorts: { } + header: { } + footer: { } + empty: { } + relationships: { } + arguments: { } + page_1: + display_plugin: page + id: page_1 + display_title: Page + position: 2 + display_options: + display_extenders: { } + path: test-filter-taxonomy-index-tid