diff --git a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php index 516495c92117c15f8c59e912d467ecad9e0cadb2..e9c4c9368d6ba5bdabfb6c44ea21fa7783f92441 100644 --- a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php @@ -2,7 +2,6 @@ namespace Drupal\taxonomy\Plugin\views\filter; -use Drupal\Core\Cache\Cache; use Drupal\Core\Entity\Element\EntityAutocomplete; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; @@ -414,19 +413,6 @@ public function getCacheContexts() { return $contexts; } - /** - * {@inheritdoc} - */ - public function getCacheTags() { - $tags = parent::getCacheTags(); - $vocabulary = $this->vocabularyStorage->load($this->options['vid']); - if ($vocabulary) { - $tags = Cache::mergeTags($tags, $vocabulary->getCacheTags()); - } - $tags = Cache::mergeTags($tags, ['taxonomy_term_list:' . $this->options['vid']]); - return $tags; - } - /** * {@inheritdoc} */ diff --git a/core/modules/taxonomy/tests/fixtures/update/test-taxonomy-exposed-filter-plugin.php b/core/modules/taxonomy/tests/fixtures/update/test-taxonomy-exposed-filter-plugin.php deleted file mode 100644 index f86a2aa33644b1fbb46bec766b84e8e20f61f13f..0000000000000000000000000000000000000000 --- a/core/modules/taxonomy/tests/fixtures/update/test-taxonomy-exposed-filter-plugin.php +++ /dev/null @@ -1,19 +0,0 @@ -<?php - -/** - * @file - * Test fixture. - */ - -use Drupal\Core\Database\Database; -use Drupal\Core\Serialization\Yaml; - -$connection = Database::getConnection(); - -$connection->insert('config') - ->fields([ - 'collection' => '', - 'name' => 'views.view.test_filter_taxonomy_index_tid', - 'data' => serialize(Yaml::decode(file_get_contents('core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_filter_taxonomy_index_tid.yml'))), - ]) - ->execute(); diff --git a/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_taxonomy_exposed_filter.yml b/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_taxonomy_exposed_filter.yml deleted file mode 100644 index 7de76bb81fc25563f638fc96396c5814ce7862c9..0000000000000000000000000000000000000000 --- a/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_taxonomy_exposed_filter.yml +++ /dev/null @@ -1,245 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - taxonomy.vocabulary.tags - module: - - node - - taxonomy - - user -id: test_taxonomy_exposed_filter -label: 'Test Taxonomy Exposed Filter' -module: views -description: '' -tag: '' -base_table: node_field_data -base_field: nid -display: - default: - display_plugin: default - id: default - display_title: Default - position: 0 - 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: mini - 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: ‹‹ - next: ›› - 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 - entity_type: node - entity_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 - settings: - link_to_entity: true - plugin_id: field - 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 - click_sort_column: value - type: string - group_column: value - group_columns: { } - group_rows: true - delta_limit: 0 - delta_offset: 0 - delta_reversed: false - delta_first_last: false - multi_type: separator - separator: ', ' - field_api_classes: false - filters: - status: - value: '1' - table: node_field_data - field: status - plugin_id: boolean - entity_type: node - entity_field: status - id: status - expose: - operator: '' - operator_limit_selection: false - operator_list: { } - group: 1 - tid: - id: tid - table: taxonomy_index - field: tid - relationship: none - group_type: group - admin_label: '' - operator: or - value: { } - group: 1 - exposed: true - expose: - operator_id: tid_op - label: 'Has taxonomy term' - description: '' - use_operator: false - operator: tid_op - operator_limit_selection: false - operator_list: { } - identifier: tid - required: false - remember: false - multiple: false - remember_roles: - authenticated: authenticated - anonymous: '0' - administrator: '0' - 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: - created: - id: created - table: node_field_data - field: created - order: DESC - entity_type: node - entity_field: created - plugin_id: date - relationship: none - group_type: group - admin_label: '' - exposed: false - expose: - label: '' - granularity: second - header: { } - footer: { } - empty: { } - relationships: { } - arguments: { } - display_extenders: { } - cache_metadata: - max-age: -1 - contexts: - - 'languages:language_content' - - 'languages:language_interface' - - url - - url.query_args - - user - - 'user.node_grants:view' - - user.permissions - tags: - - 'config:taxonomy.vocabulary.tags' - - 'taxonomy_term_list:tags' - page_1: - display_plugin: page - id: page_1 - display_title: Page - position: 1 - display_options: - display_extenders: { } - path: test-taxonomy-exposed-filter - cache_metadata: - max-age: -1 - contexts: - - 'languages:language_content' - - 'languages:language_interface' - - url - - url.query_args - - user - - 'user.node_grants:view' - - user.permissions - tags: - - 'config:taxonomy.vocabulary.tags' - - 'taxonomy_term_list:tags' diff --git a/core/modules/taxonomy/tests/src/Functional/Update/TaxonomyFilterCacheTagsUpdateTest.php b/core/modules/taxonomy/tests/src/Functional/Update/TaxonomyFilterCacheTagsUpdateTest.php deleted file mode 100644 index d5e7012b3346a72cf8d133704750eef5473bfebc..0000000000000000000000000000000000000000 --- a/core/modules/taxonomy/tests/src/Functional/Update/TaxonomyFilterCacheTagsUpdateTest.php +++ /dev/null @@ -1,61 +0,0 @@ -<?php - -namespace Drupal\Tests\taxonomy\Functional\Update; - -use Drupal\FunctionalTests\Update\UpdatePathTestBase; -use Drupal\views\Entity\View; - -/** - * Tests the upgrade path for adding cache tags to views. - * - * For the views with "taxonomy_index_tid" filter plugin, we are re-saving - * and adding necessary cache tags. - * - * @see views_post_update_add_tid_cache_tags() - * - * @group taxonomy - */ -class TaxonomyFilterCacheTagsUpdateTest extends UpdatePathTestBase { - - /** - * {@inheritdoc} - */ - protected function setDatabaseDumpFiles(): void { - $this->databaseDumpFiles = [ - __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-9.4.0.bare.standard.php.gz', - __DIR__ . '/../../../fixtures/update/test-taxonomy-exposed-filter-plugin.php', - ]; - } - - /** - * Tests the upgrade path for adding cache tags to views. - * - * For the views with "taxonomy_index_tid" filter plugin, we are re-saving - * and adding necessary cache tags. - */ - public function testViewsPostUpdateAddTidCacheTags(): void { - /** @var \Drupal\views\Entity\View $view */ - $config = \Drupal::configFactory()->get('views.view.test_filter_taxonomy_index_tid'); - $cache_tags = [ - 'config:taxonomy.vocabulary.tags', - 'taxonomy_term_list:tags', - ]; - $this->assertNotEquals($cache_tags, $config->getCacheTags()); - - $this->runUpdates(); - - /** @var \Drupal\views\Entity\View $view */ - $view = View::load('test_filter_taxonomy_index_tid'); - $view_executable = $view->getExecutable(); - $view_executable->initDisplay(); - $cache_metadata = $view_executable->getDisplay()->calculateCacheMetadata(); - - $cache_tags = [ - 'config:taxonomy.vocabulary.tags', - 'taxonomy_term_list:tags', - ]; - $this->assertEquals($cache_tags, $cache_metadata->getCacheTags()); - - } - -} diff --git a/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php index 4e4c8383eae2cea65ebb5b7b2ac16aa22f99c631..173460d4b2fbc9c25d10912baeb7323ef5d87f58 100644 --- a/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php +++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php @@ -28,7 +28,6 @@ class TaxonomyIndexTidUiTest extends UITestBase { 'test_filter_taxonomy_index_tid', 'test_taxonomy_term_name', 'test_taxonomy_exposed_grouped_filter', - 'test_taxonomy_exposed_filter', ]; /** @@ -359,20 +358,4 @@ public function testExposedUnpublishedFilterOptions() { $this->assertEmpty($this->cssSelect('option[value="' . $this->terms[1][0]->id() . '"]')); } - /** - * Test to ensure that term exists in views exposed form after it is created. - */ - public function testExposedFilterOptions() { - $this->drupalGet('test-taxonomy-exposed-filter'); - $this->assertSession()->optionExists('edit-tid', 'Term 1.0'); - $term = Term::create([ - 'vid' => 'tags', - 'name' => "Test Term", - 'parent' => 0, - ]); - $term->save(); - $this->drupalGet('test-taxonomy-exposed-filter'); - $this->assertSession()->optionExists('edit-tid', 'Test Term'); - } - } diff --git a/core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyIndexTidFilterTest.php b/core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyIndexTidFilterTest.php index d54bc88443edc3545950e5b35c19e20fc6cc764c..e58429f64d94f8c9e27b80a84eb4fa30e4c88995 100644 --- a/core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyIndexTidFilterTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyIndexTidFilterTest.php @@ -19,7 +19,7 @@ class TaxonomyIndexTidFilterTest extends TaxonomyTestBase { /** * {@inheritdoc} */ - public static $testViews = ['test_filter_taxonomy_index_tid__non_existing_dependency', 'test_filter_taxonomy_index_tid']; + public static $testViews = ['test_filter_taxonomy_index_tid__non_existing_dependency']; /** * @var \Drupal\taxonomy\TermInterface[] @@ -99,21 +99,4 @@ public function testConfigDependency() { ], $view->calculateDependencies()->getDependencies()); } - /** - * Tests that the cache tags for the chosen vocabulary are added. - */ - public function testGetCacheTags() { - /** @var \Drupal\views\Entity\View $view */ - $view = View::load('test_filter_taxonomy_index_tid'); - $view_executable = $view->getExecutable(); - $view_executable->initDisplay(); - $cache_metadata = $view_executable->getDisplay()->calculateCacheMetadata(); - - $expected_cache_tags = [ - 'config:taxonomy.vocabulary.tags', - 'taxonomy_term_list:tags', - ]; - $this->assertEquals($expected_cache_tags, $cache_metadata->getCacheTags()); - } - } diff --git a/core/modules/views/views.post_update.php b/core/modules/views/views.post_update.php index dbe5717eb67cc5dc82973beac809b319a1e390c0..60e024b6e161332c53df74497b2d6ef357decb75 100644 --- a/core/modules/views/views.post_update.php +++ b/core/modules/views/views.post_update.php @@ -94,28 +94,3 @@ function views_post_update_fix_revision_id_part(&$sandbox = NULL): void { return $view_config_updater->needsRevisionFieldHyphenFix($view); }); } - -/** - * Add missing taxonomy cache tags to views. - */ -function views_post_update_add_tid_cache_tags(&$sandbox = NULL): void { - // Re-save all existing views to force cache tags to be recalculated.This will - // add the missing taxonomy cache tag for views using the taxonomy filter. - \Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'view', function ($view) { - $display_settings = $view->get('display'); - $save = FALSE; - foreach ($display_settings as &$display) { - if (!empty($display['display_options']['filters'])) { - foreach ($display['display_options']['filters'] as &$filter_value) { - if (!array_key_exists('exposed', $filter_value)) { - continue; - } - if ($filter_value['exposed'] === TRUE && $filter_value['plugin_id'] == 'taxonomy_index_tid') { - $save = TRUE; - } - } - } - } - return $save; - }); -}