Problem/Motivation

Field UI allows you to select multiple target bundles for a field. However, the views term filter only allows you to filter on terms from a single vocabulary.

Proposed resolution

Allow to set multiple vocabularies

Before:

After:

Remaining tasks

Pleaes review MR !3681 see #242 and #247 for details.

User interface changes

Site builders are able to filter on terms across multiple taxonomy vocabularies (see the screenshots).

API changes

None.

Data model changes

The 'vid' key in 'views.filter.taxonomy_index_tid' config schema is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. The new key 'vids' (sequence of strings) is added to 'views.filter.taxonomy_index_tid' config schema as the replacement.

Release notes snippet

When using the Has taxonomy term views filters, site builders are able to filter on terms across multiple vocabularies.

CommentFileSizeAuthor
#286 2784233-286.patch41.98 KBhmdnawaz
#284 2784233-11.3.x.patch42.05 KBtikaszvince
#283 2784233-11.x.patch45.13 KBtikaszvince
#276 2784233-nr-bot.txt90 bytesneeds-review-queue-bot
#270 2784233-270.patch38.65 KBtikaszvince
#266 2784233-266.patch36.15 KBershov.andrey
#264 2784233-264-from-262.patch39.5 KBevac9
#262 2784233-262.patch39.57 KBcharlliequadros
#261 2784233-mr6023-261.patch47.13 KBalt.dev
#257 2784233-patch-reroll-from-mr3681-257.patch39.7 KBjaydip makawana
#256 2784233-patch-reroll-from-mr3681-256.patch39.72 KBjaydip makawana
#255 2784233-patch-reroll-from-mr3681-255.patch39.72 KBjaydip makawana
#238 2784233-238.patch30.97 KBjungle
#238 intediff-232-238.txt661 bytesjungle
#232 interdiff-231-232.txt5.21 KBjungle
#232 2784233-232.patch30.97 KBjungle
#231 interdiff-230-231.txt3.32 KBjungle
#231 2784233-231.patch31.99 KBjungle
#230 interdiff-229-230.txt1.76 KBjungle
#230 2784233-230.patch33.05 KBjungle
#229 interdiff-227-229.txt3.75 KBjungle
#229 2784233-229.patch32.81 KBjungle
#227 interdiff-225-227.txt1.89 KBjungle
#227 2784233-227.patch31.71 KBjungle
#225 2784233-225.patch31.81 KBjungle
#225 raw-interdiff-219-225.txt5.88 KBjungle
#223 interdiff_222-223.txt3.75 KBpradhumanjain2311
#223 2784233-223.patch31.02 KBpradhumanjain2311
#222 interdiff_220-222.txt626 bytespradhumanjain2311
#222 2784233-222.patch31.01 KBpradhumanjain2311
#221 10.1.x.png48.76 KBbebalachandra
#220 2784233-220.patch30.99 KBameymudras
#219 interdiff-217-219.txt809 bytesjungle
#219 2784233-219.patch33.26 KBjungle
#217 interdiff-212-217.txt4.57 KBjungle
#217 2784233-217.patch33.25 KBjungle
#212 2784233-212.patch32.43 KBahebrank
#211 2784233-211.patch32.44 KBahebrank
#199 After Patch 2784233.png364.46 KBchetanbharambe
#199 Before Patch 2784233 up.png360.24 KBchetanbharambe
#195 before_patch.png11.46 KBradheymkumar
#195 after_patch.png11.03 KBradheymkumar
#193 interdiff-191-193.txt1.17 KBjungle
#193 2784233-193.patch32.67 KBjungle
#191 interdiff-179-191.txt9.95 KBjungle
#191 2784233-191.patch31.85 KBjungle
#184 exposed-filter-end-user-display.png183.94 KBshelane
#184 exposed-filter-settings.png114.57 KBshelane
#184 exposed-filter-views-settings.png55.88 KBshelane
#181 latest.png75.89 KBshelane
#181 previous.png185.62 KBshelane
#179 2784233-179.patch32.75 KBshelane
#176 interdiff-171-176.txt1.86 KBkishor_kolekar
#176 2784233-176.patch36.36 KBkishor_kolekar
#171 interdiff_168-171.txt2.25 KBvsujeetkumar
#171 2784233-171.patch36.48 KBvsujeetkumar
#169 2784233-169.patch36.43 KBkapilv
#168 2784233-9.1.x-168.patch35.91 KBdrewble
#166 2784233-9.1.x-166.patch36.63 KBdrewble
#164 2784233-9.1.x-164.patch5.02 KBdrewble
#163 2784233-9.1.x-163.patch28.26 KBdrewble
#160 2784233-9.1.x-160.patch29.61 KBshelane
#152 after_patch.png7.5 KBgauravvvv
#152 before_patch.png20.29 KBgauravvvv
#149 2784233-after_patch-140.png11.03 KBabhijith s
#149 2784233-before_patch-140.png11.46 KBabhijith s
#148 2784233-8.9.x-148.patch32.92 KBperelesnyk
#145 Test.png89.75 KBpaulocs
#141 2784233-8.9.x-141.patch347.88 KBperelesnyk
#140 2784233-140.patch32.86 KBclaudiu.cristea
#140 2784233-140.interdiff.txt1.67 KBclaudiu.cristea
#138 2784233-138.patch32.76 KBclaudiu.cristea
#138 2784233-129-to-138.interdiff.txt4.13 KBclaudiu.cristea
#130 interdiff-129-130.txt6.38 KBjungle
#130 2784233-130.patch30.09 KBjungle
#129 tid_grouped.png189.04 KBclaudiu.cristea
#129 2784233-129.patch30.55 KBclaudiu.cristea
#129 2784233-129.interdiff.txt3.49 KBclaudiu.cristea
#127 interdiff-9.1.x-122-127.txt856 bytesjungle
#127 2784233-9.1.x-127.patch29.73 KBjungle
#127 interdiff-8.9.x-122-127.txt2.42 KBjungle
#127 2784233-8.9.x-127.patch29.72 KBjungle
#123 raw-interdiff-9.1.x-115-122.txt696 bytesjungle
#122 raw-interdiff-8.9.x-115-122.txt3.5 KBjungle
#122 2784233-9.1.x-122.patch29.73 KBjungle
#122 2784233-8.9.x-122.patch28.94 KBjungle
#116 vocab-split.png250.18 KBclaudiu.cristea
#116 multi-vocab.png80.82 KBclaudiu.cristea
#115 2784233-115.patch29.73 KBclaudiu.cristea
#115 2784233-115.interdiff.txt2.52 KBclaudiu.cristea
#112 2784233-112.patch29.76 KBclaudiu.cristea
#112 2784233-112.interdiff.txt2.07 KBclaudiu.cristea
#112 tid_filter_after.png70.74 KBclaudiu.cristea
#112 tid_filter_before.png71.46 KBclaudiu.cristea
#111 2784233-111.patch29.78 KBclaudiu.cristea
#110 2784233-110.patch29.81 KBclaudiu.cristea
#110 2784233-110.interdiff.txt781 bytesclaudiu.cristea
#109 2784233-109.patch29.81 KBclaudiu.cristea
#109 2784233-109.diff.txt10.17 KBclaudiu.cristea
#106 2784233-106.patch26.96 KBclaudiu.cristea
#106 2784233-106.interdiff.txt6.74 KBclaudiu.cristea
#105 Screen Shot 2020-07-12 at 4.54.35 PM.png297.36 KBtanubansal
#105 Screen Shot 2020-07-12 at 4.54.35 PM.png297.36 KBtanubansal
#104 allow_multiple_vocabularies.png75.68 KBmayurjadhav
#104 allow_multiple_vocabularies-2784233-8.9-104.patch22.5 KBmayurjadhav
#104 allow_multiple_vocabularies-2784233-9.1-104.patch22.53 KBmayurjadhav
#101 interdiff.2784233.90-101.txt4.07 KBaleevas
#101 2784233-9.1-101.patch22.8 KBaleevas
#91 multiple-vocabularies-after-patch.png150.78 KBvinodhini.e
#91 multiple-vocabularies-before-patch.png145.4 KBvinodhini.e
#90 multiple-vocabularies-filter-2784233-90.patch23.16 KBjungle
#90 interdiff-88-90.txt794 bytesjungle
#88 multiple-vocabularies-filter-2784233-88.patch23.03 KBjungle
#86 2784233-86.patch23.03 KBrensingh99
#86 interdiff.txt2.67 KBrensingh99
#86 after_patch.png7.5 KBrensingh99
#86 before_patch.png20.29 KBrensingh99
#86 git_error.png7.96 KBrensingh99
#81 diff_79-81.txt1.24 KBkostyashupenko
#81 2784233-81.patch22.78 KBkostyashupenko
#79 interdiff-2784233-75-79.txt2.45 KByogeshmpawar
#79 2784233-79.patch22.88 KByogeshmpawar
#76 interdiff-73-75.txt381 bytesahebrank
#75 interdiff-73-75.txt0 bytesahebrank
#75 taxonomy-multiple_vocab_filte-8.7.x-2784233-75.patch22.87 KBahebrank
#73 taxonomy-multiple_vocab_filte-8.7.x-2784233-73.patch22.86 KBahebrank
#71 taxonomy-multiple_vocab_filter-2784233-71.patch22.86 KBahebrank
#66 taxonomy-multiple_vocab_filter-2784233-66.patch25.98 KBgpap
#65 interdiff.txt11.33 KBahebrank
#65 taxonomy-multiple_vocab_filter-2784233-65.patch22.76 KBahebrank
#64 interdiff.txt10.68 KBahebrank
#64 taxonomy-multiple_vocab_filter-2784233-64.patch22.13 KBahebrank
#63 interdiff.txt4.32 KBahebrank
#63 taxonomy-multiple_vocab_filter-2784233-62.patch28.4 KBahebrank
#62 interdiff.txt736 bytesahebrank
#62 taxonomy-multiple_vocab_filter-2784233-61.patch25.46 KBahebrank
#61 taxonomy-multiple_vocab_filter-2784233-60.patch24.79 KBahebrank
#59 taxonomy-multiple_vocab_filter-2784233-57.patch26.01 KBrudranil29
#56 taxonomy-multiple_vocab_filter-2784233-56.patch25.89 KBkennethos
#55 taxonomy-multiple_vocab_filter-2784233-55.patch26.01 KBkennethos
#53 taxonomy-multiple_vocab_filter-2784233-53.patch24.59 KBotherl
#47 taxonomy-multiple_vocab_filter-2784233-47.patch24.81 KBgpap
#45 taxonomy-multiple_vocab_filter-2784233-45.patch29.3 KBkbasarab
#44 taxonomy-allow_multiple_vocabularies_in_taxonomy_filter-2784233.patch29.21 KBedwardchiapet
#41 interdiff.txt1.52 KBdawehner
#41 2784233-41.patch22.46 KBdawehner
#34 2784233-32.patch28.56 KBclaudiu.cristea
#32 2784233-32.patch28.56 KBlendude
#32 interdiff-2784233-17-32.txt4.08 KBlendude
#26 selectvocabafter.png39.06 KBlendude
#17 interdiff.txt2.26 KBclaudiu.cristea
#17 2784233-17.patch22.17 KBclaudiu.cristea
#16 interdiff.txt7.82 KBclaudiu.cristea
#16 2784233-16.patch22.27 KBclaudiu.cristea
#14 interdiff.txt1.42 KBclaudiu.cristea
#14 2784233-14.patch21.61 KBclaudiu.cristea
#11 interdiff.txt850 bytesdawehner
#11 2784233-11.patch20.72 KBdawehner
#9 interdiff.txt2.04 KBdawehner
#9 2784233-9.patch20.73 KBdawehner
#7 interdiff.txt984 bytesdawehner
#7 2784233-7.patch20.64 KBdawehner
#5 interdiff.txt15.59 KBdawehner
#5 2784233-5.patch20.59 KBdawehner
#4 vocab_select.png34.57 KBlendude
#2 2784233-2.patch6.03 KBdawehner

Issue fork drupal-2784233

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dawehner created an issue. See original summary.

dawehner’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new6.03 KB

Here is a start for this bug

dawehner’s picture

lendude’s picture

Status: Needs review » Needs work
StatusFileSize
new34.57 KB

Yeah this change makes sense.

Currently looks like this:

Couple of things

  1. +++ b/core/modules/taxonomy/config/schema/taxonomy.views.schema.yml
    @@ -123,6 +123,11 @@ views.filter.taxonomy_index_tid:
         vid:
           type: string
           label: 'Vocabulary'
    

    this can be removed I'd say

  2. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -147,9 +151,18 @@ public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) {
    +    $vocabulary = reset($vocabularies);
    

    This is still used for the 'Dropdown' option. So with the current patch the Dropdown option still just uses one vocabulary.

And it obviously needs tests and an upgrade path, but the idea makes sense.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new20.59 KB
new15.59 KB

Here is an update path, a test and an update path test.

Status: Needs review » Needs work

The last submitted patch, 5: 2784233-5.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new20.64 KB
new984 bytes

Just fixed it.

lendude’s picture

Status: Needs review » Needs work

Looking good. Couple of things I see:

  1. +++ b/core/modules/taxonomy/config/schema/taxonomy.views.schema.yml
    @@ -123,6 +123,11 @@ views.filter.taxonomy_index_tid:
         vid:
           type: string
           label: 'Vocabulary'
    

    'vid' should now be redundant so we should remove it

  2. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -147,9 +155,33 @@ public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) {
    +      $form_state->setErrorByName('options][vids', $this->t("You cannot select more than one vocabulary, when choosing 'Dropdown' as selection type."));
    

    Any reason for not allowing this other then 'limited use-case' (large lists in select == bad idea)?

  3. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -158,8 +190,11 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
    +        '#title' => $this->options['limit'] ? $this->t('Select terms from vocabularies @vocs', array('@vocs' => implode(', ', $vocabulary_labels))) : $this->t('Select terms'),
    

    Any easy way to make this into a better sentence when we have multiple vocabs? now it would be "voc1, voc2, voc3" but it would be nice to have "voc1, voc2 and voc3"

  4. +++ b/core/modules/taxonomy/src/Tests/Views/Update/TaxonomyIndexTidUpdateTest.php
    @@ -0,0 +1,41 @@
    +    // Check that the field is using the expected base table.
    

    copy/paste leftover? 'is using vids' or something.

  5. +++ b/core/modules/taxonomy/src/Tests/Views/Update/TaxonomyIndexTidUpdateTest.php
    @@ -0,0 +1,41 @@
    +    $this->assertTrue(empty($data['display']['default']['display_options']['filters']['tid']['vid']));
    

    shouldn't this be more strict and use !isset() instead of empty()? We want to make sure the 'vid' key is gone from config, not just that it's empty.

  6. +++ b/core/modules/taxonomy/taxonomy.post_update.php
    @@ -0,0 +1,41 @@
    + * Update the cacheability metadata for all views.
    

    copy/paste leftover, needs update.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new20.73 KB
new2.04 KB

Thank you @lendude for the review!

Any reason for not allowing this other then 'limited use-case' (large lists in select == bad idea)?

Well, the current logic is build around the idea of using $termStorage->loadTree() which requires one to specify a single vocabulary. What about trying to implement that as a follow up?

Any easy way to make this into a better sentence when we have multiple vocabs? now it would be "voc1, voc2, voc3" but it would be nice to have "voc1, voc2 and voc3"

I asked in the drupalux slack channel, what they thing about this pattern. In case we do that, it would be nice to have a common helper for it.

copy/paste leftover? 'is using vids' or something.

Good catch!

shouldn't this be more strict and use !isset() instead of empty()? We want to make sure the 'vid' key is gone from config, not just that it's empty.

Sure, let's go with that.

claudiu.cristea’s picture

  1. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -96,13 +100,16 @@ protected function defineOptions() {
    +    $options['vids'] = array('default' => []);
    

    Weird that we keep the array() syntax on the outer array while using the square bracket syntax on the inner array :)

  2. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -147,9 +155,33 @@ public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) {
    +  }
    +
    +
    +  /**
    

    Extra empty line.

dawehner’s picture

StatusFileSize
new20.72 KB
new850 bytes

Thank you for your review @claudiu.cristea!

Sure, let's fix that.

The last submitted patch, 9: 2784233-9.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 11: 2784233-11.patch, failed testing.

claudiu.cristea’s picture

Status: Needs work » Needs review
StatusFileSize
new21.61 KB
new1.42 KB

let's see

dawehner’s picture

Thank you @claudiu.cristea!
What are your other thoughts about this particular patch?

claudiu.cristea’s picture

StatusFileSize
new22.27 KB
new7.82 KB

@dawehner, well, it looks good to me and I think it makes sense. I did some cleanup, improved the update path test, nits, etc.

+++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
@@ -78,7 +79,10 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
+    if (empty($this->options['vids']) && !empty($this->options['vid'])) {
+      $this->options['vids'] = [$this->options['vid']];
     }

I removed this because I felt that was a "non-transparent" try to hide an update path :) Now we have a dedicated update path so it doesn't make sense anymore.

Good to go, IMO.

claudiu.cristea’s picture

StatusFileSize
new22.17 KB
new2.26 KB

Even more cleanup.

dawehner’s picture

Status: Needs review » Needs work

I removed this because I felt that was a "non-transparent" try to hide an update path :) Now we have a dedicated update path so it doesn't make sense anymore.

Good point!

  1. +++ b/core/modules/taxonomy/src/Tests/Views/Update/TaxonomyIndexTidUpdateTest.php
    @@ -19,7 +19,7 @@ class TaxonomyIndexTidUpdateTest extends UpdatePathTestBase {
         $this->databaseDumpFiles = [
    -      __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
    +      __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8-rc1.bare.standard.php.gz',
           __DIR__ . '/../../../../tests/fixtures/update/taxonomy-index-filter-multiple-vocabularies.php',
    

    Good point

  2. +++ b/core/modules/taxonomy/tests/fixtures/update/taxonomy-index-filter-multiple-vocabularies.php
    @@ -10,10 +10,14 @@
    +$view_config = Yaml::decode(file_get_contents('core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_filter_taxonomy_index_tid_pre_update.yml'));
    +unset($view_config['display']['default']['display_options']['filters']['tid']['vids']);
    +$view_config['display']['default']['display_options']['filters']['tid']['vid'] = 'tags';
    +
    

    Why do we have to do that? This particular view should not have tid stuff in the first place.

claudiu.cristea’s picture

Status: Needs work » Needs review

Why do we have to do that? This particular view should not have tid stuff in the first place.

@dawehner, if we put vid: tags (the old schema) directly in the .yml then Drupal\Tests\views\Kernel\TestViewsTest::testDefaultConfig() fails:

$ ./vendor/bin/phpunit -c core --filter TestViewsTest
PHPUnit 4.8.11 by Sebastian Bergmann and contributors.

F

Time: 9.19 seconds, Memory: 291.00Mb

There was 1 failure:

1) Drupal\Tests\views\Kernel\TestViewsTest::testDefaultConfig
Schema key views.view.test_filter_taxonomy_index_tid_pre_update:display.default.display_options.filters.tid.vid failed with: missing schema

core/modules/config/src/Tests/SchemaCheckTestTrait.php:43
core/modules/views/tests/src/Kernel/TestViewsTest.php:52

See https://www.drupal.org/pift-ci-job/428187.

That's why we need to add the new schema in the .yml and then just swap to the old one when the fixture applies.

The last submitted patch, 16: 2784233-16.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 17: 2784233-17.patch, failed testing.

claudiu.cristea’s picture

Status: Needs work » Needs review
dawehner’s picture

Issue summary: View changes

@dawehner, if we put vid: tags (the old schema) directly in the .yml then Drupal\Tests\views\Kernel\TestViewsTest::testDefaultConfig() fails:

Ah fair point. Yeah, let's keep it like that then. I would RTBC if I wouldn't have written a good bunch of it :P

Status: Needs review » Needs work

The last submitted patch, 17: 2784233-17.patch, failed testing.

claudiu.cristea’s picture

Status: Needs work » Needs review
lendude’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new39.06 KB

Looks good now. All feedback has been addressed, we have a fix, we have tests, we have an update path (+test). Manually tested this and that works too.

Added before/after screenshots to the IS.

jacine’s picture

I'd just like to chime in to say I've been testing this patch and it all (finally) works as advertised. Thank you!

catch’s picture

What happens if you have a module providing default config after this change (if they don't update it)?

dawehner’s picture

Mh, they would indeed sort of break. One thing we could do is to provide some kind of inline BC bit. Do you think this would be okay? Basically exactly what #2784233-16: Allow multiple vocabularies in the taxonomy filter had.

catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +needs bc layer

Yes I think that's worth doing. The existing configuration works - i.e. it's not stored incorrectly, so we should try to keep those views working.

Is it worth looking at isolating the bc layer to the config installer somewhere? Every other case is covered by either the upgrade path or the protections against deploying between different versions of core.

dawehner’s picture

Is there some form of event which is just fired on config import?

lendude’s picture

StatusFileSize
new4.08 KB
new28.56 KB

Is there some form of event which is just fired on config import?

Took a stab at this with an EventSubscriber fired on ConfigEvents::IMPORT, works nicely for config imported, but doesn't fire on module install, so it doesn't cover all the cases. Also it gives a lot of duplicated code, which is not pretty.

Just thinking out loud here, I'd be against adding BC code like this

+++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
@@ -81,9 +81,6 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
    if (empty($this->options['vids']) && !empty($this->options['vid'])) {
      $this->options['vids'] = [$this->options['vid']];
    }

That would lead to BC code scattered throughout the code base, which sounds like a cleanup nightmare. Having one place where we deal with updating outdated config sounds much better to me. Something like running post_updates on config import and module install. Something like that would also allow us to give a nice message that some outdated config was imported and alert module maintainers that something needs to be updated.

With more config updates in the making should we look at a way to handle this properly. #2459289: Boolean default values are not saved ran into the same thing. There an update wasn't needed, but it still leads to outdated config being imported. I can only imagine this happening more in the future.

Adding a patch with the eventlistener just for reference here. Interdiff looks a bit weird

claudiu.cristea’s picture

Status: Needs work » Needs review
claudiu.cristea’s picture

StatusFileSize
new28.56 KB

Repost patch from #32.

Status: Needs review » Needs work

The last submitted patch, 34: 2784233-32.patch, failed testing.

dawehner’s picture

IMHO the only case we need to actually cover is the module install one. The other one, like import is actually not needed, because those installations with all executed the update hook already.

Given that using hook_view_insert seems to be a good approach to solve the problem. Thoughts?

lendude’s picture

@dawehner I agree that the most important scenario to cover is the install one, I was hoping ConfigEvents::IMPORT would fire on install, but alas....

hook_view_insert could work, but I think would add unnecessary overhead in scenarios where it's not needed (most commonly, just creating a new view through the UI). Since I think we will see more of these config changes in the future, this overhead might become significant.

Maybe hook_modules_installed? which at least only fires when we want it to, but would need to check all config and not just the new one, which sounds bad.

But to be honest, we need something generic to deal with this. There are 3 ways that out-of-date config can occur:

  1. Already installed when the update occurs
  2. On import
  3. On module install

Currently only #1 is covered. And we need some way to cover all three going forward, and preferably not by copy/pasting the same code in 3 different hooks, right?

catch’s picture

I doubt doing this in hook_view_insert() would have much overhead even if we're not able to differentiate between default config and config created via the UI in there - should only be an isset/is_array check anyway. Agreed that seems like a good place to do it. If we do eventually end up with lots of these and there's noticeable overhead, we can at least remove them in 9.x.

This from ConfigInstaller::createConfiguration() is the only thing I can find differentiating between new config via module defaults vs. new config from anywhere else.

        // Add a hash to configuration created through the installer so it is
        // possible to know if the configuration was created by installing an
        // extension and to track which version of the default config was used.
        if (!$this->isSyncing() && $collection == StorageInterface::DEFAULT_COLLECTION) {
          $new_config->set('_core.default_config_hash', Crypt::hashBase64(serialize($config_to_create[$name])));
        }
dawehner’s picture

Already installed when the update occurs
On import
On module install

I actually believe that onimport shouldn't be an issue. If people run update.php, they'll get the chances. They should do that both on the production but also on the development environment. The remaining one, as explained by catch, could be dealt with.

Can we agree on that?

lendude’s picture

@dawehner Yeah, fair enough. The edge case where someone imports outdated config after already running update.php sounds like something we shouldn't really worry about too much (and sounds more like a 'fix your workflow' issue).

dawehner’s picture

Status: Needs work » Needs review
Issue tags: -needs bc layer
StatusFileSize
new22.46 KB
new1.52 KB

What about simply adding the same logic on here again?

Status: Needs review » Needs work

The last submitted patch, 41: 2784233-41.patch, failed testing.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

edwardchiapet’s picture

Attached is a reroll of the patch for 8.3.1.

kbasarab’s picture

Here is a reroll to support 8.3.5 just to keep this up to date. Active dev should still move to 8.4.x though.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

gpap’s picture

[deleted]

lendude’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 47: taxonomy-multiple_vocab_filter-2784233-47.patch, failed testing. View results

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

tomsaw’s picture

I've used this Patch until now... but the last comment is 5months ago :O
Isn't the Feature of having multiple taxonomy terms focused anymore or did i miss a new feature which makes the pathc redundant?

otherl’s picture

Reroll for 8.5.1.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

kennethos’s picture

Made some changes to allow the dropdown widget in views when selecting multiple vocabularies. The exposed form options will contain all terms from the selected vocabularies.

kennethos’s picture

Reroll against 8.5.x

manish-31’s picture

@kennethos patch #56 failed for 8.7.x-dev.

gpap’s picture

[deleted]

rudranil29’s picture

Assigned: Unassigned » rudranil29
Status: Needs work » Needs review
StatusFileSize
new26.01 KB

return $vocabulary->label();q
q is removed. from patch

Status: Needs review » Needs work

The last submitted patch, 59: taxonomy-multiple_vocab_filter-2784233-57.patch, failed testing. View results

ahebrank’s picture

Rerolled 57 to apply to 8.6 / 8.7. I'm using with 8.6.2 and seems to be working so far.

ahebrank’s picture

StatusFileSize
new25.46 KB
new736 bytes

This might fix the schema test errors.

ahebrank’s picture

StatusFileSize
new28.4 KB
new4.32 KB

Chipping away at test errors. This adds a cast in the checkboxes render element that might be out of scope for this.

ahebrank’s picture

StatusFileSize
new22.13 KB
new10.68 KB

Removing some cruft and no longer messing with render elements. Local tests look good, so fingers crossed.

ahebrank’s picture

StatusFileSize
new22.76 KB
new11.33 KB

OK, one more -- found a node Views UI wizard using the old vocab config.

gpap’s picture

[deleted]

Paulset’s picture

Someone for this important feature ?

I have version 8.6 of Drupal and for the moment the patch have not passed validation

ahebrank’s picture

65 should work for 8.6.10, so I'm going to hide 66 since it doesn't apply.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

tomsaw’s picture

#65 fails for new Drupal 8.7.0 core with revisioned taxonomy terms

ahebrank’s picture

Reroll for 8.7.x.

tomsaw’s picture

Thanks a lot ahebrank, #71 Works !

One thing: Git moaned about trailing whitespace @line 528

ahebrank’s picture

Fixing the trailing whitespace in the patch file. Fingers crossed that's what testbot is not liking, because otherwise I'm not sure what that's about. TaxonomyIndexTidUiTest passes locally.

lendude’s picture

+++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
@@ -169,21 +192,26 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
+                  ->getTranslationFromContext($term)

The testbot is failing because of deprecations:

Remaining deprecation notices (72)

72x: EntityManagerInterface::getTranslationFromContext() is deprecated in 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Entity\EntityRepository::getTranslationFromContext() instead. See https://www.drupal.org/node/2549139.
60x in TaxonomyIndexTidUiTest::testExposedFilter from Drupal\Tests\taxonomy\Functional\Views
12x in TaxonomyIndexTidUiTest::testFilterUI from Drupal\Tests\taxonomy\Functional\Views

ahebrank’s picture

Ah, I see the regression now. Thanks.

ahebrank’s picture

StatusFileSize
new381 bytes
pancho’s picture

Assigned: rudranil29 » Unassigned
Status: Needs work » Needs review
Related issues: +#2429699: Add Views EntityReference filter to be available for all entity reference fields

This is basically a subset of #2429699: Add Views EntityReference filter to be available for all entity reference fields. Let's see which one is ready to get in first, though.

yogeshmpawar’s picture

Assigned: Unassigned » yogeshmpawar
yogeshmpawar’s picture

Assigned: yogeshmpawar » Unassigned
StatusFileSize
new22.88 KB
new2.45 KB

Resolved some coding standard issues & added an interdiff.

daffie’s picture

kostyashupenko’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new22.78 KB
new1.24 KB
daffie’s picture

Status: Needs review » Needs work

Patch looks good, almost RTBC. Some minor points left for me:

  1. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -78,7 +79,10 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
    +    if (empty($this->options['vids']) && !empty($this->options['vid'])) {
    +      $this->options['vids'] = [$this->options['vid']];
         }
    

    I would like to see a comment why we have this piece of code here.

  2. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -114,18 +121,19 @@ public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) {
    +          '#required' => TRUE,
    

    Why does the option vids need to be required, when the option vid was not?

  3. +++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php
    @@ -61,29 +95,26 @@ protected function setUp($import_test_views = TRUE) {
    -    $this->drupalGet('admin/structure/views/nojs/handler/test_filter_taxonomy_index_tid/default/filter/tid');
    +    $out = $this->drupalGet('admin/structure/views/nojs/handler/test_filter_taxonomy_index_tid/default/filter/tid');
    

    Why do we add the variable $out? It is not used anywhere.

daffie’s picture

Forgot a nitpick:

+++ b/core/modules/taxonomy/config/schema/taxonomy.views.schema.yml
@@ -120,9 +120,12 @@ views.filter.taxonomy_index_tid:
-    vid:

+++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php
@@ -126,6 +157,75 @@ public function testFilterUI() {
+  public function testFilterUIWithMoreVocabularies() {

The test has no docblock.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

freelock’s picture

Status: Needs work » Needs review

Huh. It appears that this patch made it into Drupal 8.8.0 -- or if not this patch, something extremely similar? Patch appears to be already applied....

rensingh99’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new7.96 KB
new20.29 KB
new7.5 KB
new2.67 KB
new23.03 KB

Hi,

I have reviewed the patch #81 and it had failed with 8.9x.

I have rerolled it and uploaded the patch with interdiff.

After reroll I have checked the patch and it worked as designed.

Before applying the patch:

I have added the has taxonomy field in the admin content view. And there was no option to add multiple vocabularies in the taxonomy filter.

Below are the output screenshot before applying the patch.

There is the option to add multiple vocabularies in the taxonomy filter after applying the patch.

Below is the output screenshot after applying the patch.

The patch is working great.

Thanks,
Ren

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 86: 2784233-86.patch, failed testing. View results

jungle’s picture

Status: Needs work » Needs review
StatusFileSize
new23.03 KB

Made a patch for Drupal 8.8.1, modified from #81, no interdiff as it's hard for me to make one.

Key changes:

1. renamed testFilterUIWithMoreVocabularies to testFilterUIWithMultipleVocabularies, and added docblock for it according to the comment #83

Why do we add the variable $out? It is not used anywhere.

2. Removed variable $out according to comment #82

Status: Needs review » Needs work

The last submitted patch, 88: multiple-vocabularies-filter-2784233-88.patch, failed testing. View results

jungle’s picture

Version: 8.9.x-dev » 8.8.x-dev
Status: Needs work » Needs review
StatusFileSize
new794 bytes
new23.16 KB

Try to fix the CI error by adding the following lines into taxonomy_post_update_taxonomy_index_filter_multiple_vocabularies()

  // If Views is not installed, there is nothing to do.
  if (!\Drupal::moduleHandler()->moduleExists('views')) {
    return;
  }
vinodhini.e’s picture

Version: 8.8.x-dev » 8.9.x-dev
StatusFileSize
new145.4 KB
new150.78 KB

I applied patch #90, It's working for me.
I am attaching a screenshot before and after applying the patch.

introfini’s picture

I applied patch #90, and it's also working for me.

Thanks!

maursilveira’s picture

I tested patch #90 on Drupal Core 8.8.1 and it's working as expected for me.

Thank you @jungle for the patch. Great job!

michelledarling’s picture

Tested patch #90 (on simplytest.me)

8.8.3 - applied cleanly but doesn't seem to change anything (taxonomy vocabularies are still radio buttons and I can only choose one)
Could be the patch didn't actually apply, but tried it twice with a fresh install.

8.9.dev - applied cleanly and works to give checkboxes instead of radio buttons.

I'm new to this so I apologize if I'm doing it wrong!

jungle’s picture

8.8.3 - applied cleanly but doesn't seem to change anything (taxonomy vocabularies are still radio buttons and I can only choose one)

Re #94, have you run the database update? By drush, it's drush updb or visit /update.php

dercheffe’s picture

That would be really a great enhancement for taxonomy 🤩.

rudranil29’s picture

I applied patch #90, looks good to me working fine..

dercheffe’s picture

Status: Needs review » Reviewed & tested by the community

I applied patch in #90 at simplytest.me (Drupal 8.8.5) and it's working fine for me. Please commit it. thanks.

lendude’s picture

Status: Reviewed & tested by the community » Needs work

We had an upgrade path test in #7 and that seems to have gotten lost somewhere, we need that back.

Also all the discussion earlier in the issue about updating config provided by modules has lead to the creation of \Drupal\views\ViewsConfigUpdater, so we probably need to use that for the update. That way we can update existing config but also config that gets added by newly installed modules.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

aleevas’s picture

Status: Needs work » Needs review
StatusFileSize
new22.8 KB
new4.07 KB

Re-rolled up to 9.1

jungle’s picture

Status: Needs review » Needs work

Thanks, @aleevas for the re-roll. Is #99 addressed? If #101 is just a Re-roll, the proper status should be NW. If it has been addressed, please set back to NR.

shelane’s picture

Neither patch 90 or 101 can be applied to 8.9.2.

mayurjadhav’s picture

Status: Needs work » Needs review
StatusFileSize
new22.53 KB
new22.5 KB
new75.68 KB

core/modules/taxonomy/taxonomy.post_update.php has lots of changes between 8.9 and 9.1 branch.
So I have rerolled two separate patches, Please review.
Verified it on both the versions attaching the screenshot.

tanubansal’s picture

After adding a patch, i have tested the above mentioned bug on drupal 9.1 and its resolved.
Please find before and after screenshots attached below

claudiu.cristea’s picture

StatusFileSize
new6.74 KB
new26.96 KB

Added back the tests and used ViewsConfigUpdater. However, feels strange to put taxonomy logic in Views module.

Status: Needs review » Needs work

The last submitted patch, 106: 2784233-106.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

claudiu.cristea’s picture

Few remarks:

  1. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -78,7 +79,10 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
    +    if (empty($this->options['vids']) && !empty($this->options['vid'])) {
    +      $this->options['vids'] = [$this->options['vid']];
         }
    

    This was an early BC assurance. Now we rely on ViewsConfigUpdater.

  2. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -114,18 +121,19 @@ public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) {
    -      if (empty($this->options['vid'])) {
    +      if (empty($this->options['vids'])) {
             $first_vocabulary = reset($vocabularies);
    -        $this->options['vid'] = $first_vocabulary->id();
    +        $this->options['vids'] = [$first_vocabulary->id()];
           }
    

    I don't think it's the case. If `limit` is off, we use all vocabs. If it's on and no vocab is selected, we should, probably, add a form validation error. @Lendude, could you, please, make a point here, as module maintainer?

  3. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -149,19 +160,31 @@ public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) {
             '#markup' => '<div class="js-form-item form-item">' . $this->t('An invalid vocabulary is selected. Please change it in the options.') . '</div>',
    

    This text should probably reflect that we're using more than one vocabulary

  4. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -149,19 +160,31 @@ public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) {
    +    $vocabulary_labels = array_map(function (VocabularyInterface $vocabulary) {
    

    We can use typed return for the closure. But we compute the list of vocabulary labels also in TaxonomyIndexTid::buildExtraOptionsForm(). Isn't it worth to move the closure as protected method and use it there too?

  5. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -149,19 +160,31 @@ public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) {
    -      $terms = $this->value ? Term::loadMultiple(($this->value)) : [];
    +      $terms = $this->value ? Term::loadMultiple($this->value) : [];
    

    Similarly when loading vocabularies, we should use the taxonomy_term storage instead of Term

  6. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -149,19 +160,31 @@ public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) {
    -        '#title' => $this->options['limit'] ? $this->t('Select terms from vocabulary @voc', ['@voc' => $vocabulary->label()]) : $this->t('Select terms'),
    +        '#title' => $this->options['limit'] ? $this->t('Select terms from vocabularies @vocs', ['@vocs' => implode(', ', $vocabulary_labels)]) : $this->t('Select terms'),
    
    @@ -238,7 +273,7 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
    -        '#title' => $this->options['limit'] ? $this->t('Select terms from vocabulary @voc', ['@voc' => $vocabulary->label()]) : $this->t('Select terms'),
    +        '#title' => $this->options['limit'] ? $this->t('Select terms from vocabulary @vocs', ['@vocs' => implode(', ', $vocabulary_labels)]) : $this->t('Select terms'),
    

    Shouldn't we enclose with quotes the each vocabulary label?

  7. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -195,16 +224,22 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
    -        if ($this->options['limit']) {
    -          $query->condition('vid', $vocabulary->id());
    +        $conditions = $query->orConditionGroup();
    +        foreach ($vocabularies as $vocabulary) {
    +          if ($this->options['limit']) {
    +            $conditions->condition('vid', $vocabulary->id());
    +          }
    ...
    +        $query->condition($conditions);
    

    Why not using an IN operator? Then we can pass all vids in only one condition.

  8. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -365,7 +400,9 @@ public function adminSummary() {
    -        $this->valueOptions[$term->id()] = \Drupal::service('entity.repository')->getTranslationFromContext($term)->label();
    +        $this->valueOptions[$term->id()] = \Drupal::service('entity.repository')
    +          ->getTranslationFromContext($term)
    +          ->label();
    

    Better not touch this line. Otherwise I'm forced to request this service to be injected :)

claudiu.cristea’s picture

Status: Needs work » Needs review
Issue tags: +Needs change record
StatusFileSize
new10.17 KB
new29.81 KB

Fix tests, #108, coding standards. Needs change record for introduced deprecation.

claudiu.cristea’s picture

StatusFileSize
new781 bytes
new29.81 KB

Oops!

claudiu.cristea’s picture

StatusFileSize
new29.78 KB

Rerolled.

claudiu.cristea’s picture

Issue summary: View changes
Issue tags: -Needs change record
StatusFileSize
new71.46 KB
new70.74 KB
new2.07 KB
new29.76 KB
claudiu.cristea’s picture

Issue summary: View changes
lendude’s picture

Looks really great, just one question really:

+++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
@@ -149,19 +163,31 @@ public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) {
-        '#title' => $this->options['limit'] ? $this->t('Select terms from vocabulary @voc', ['@voc' => $vocabulary->label()]) : $this->t('Select terms'),
+        '#title' => $this->options['limit'] ? $this->t("Select terms from vocabularies @vocabs", [
+          '@vocabs' => $vocabulary_labels,
+        ]) : $this->t('Select terms'),

Should we have a singular/plural here, cause this will look weird if you only have one vocab selected? And since we are generating this title twice maybe do it in a protected method?

On #108.2, I agree with the path you've chosen @claudiu.cristea, showing an error when you have chosen to limit options and then not chosen any vocabs makes sense to me.

claudiu.cristea’s picture

StatusFileSize
new2.52 KB
new29.73 KB

@Lendude

Should we have a singular/plural here, cause this will look weird if you only have one vocab selected?

Indeed. Fixed.

And since we are generating this title twice maybe do it in a protected method?

I went with a different approach to resolve the code duplication.

claudiu.cristea’s picture

Issue summary: View changes
StatusFileSize
new80.82 KB
new250.18 KB

@Lendude, now I see a UX problem when more than one vocabulary is selected. With these vocabs selected:

I see a list of terms but it might be difficult for the site builder to distinguish which term belong to which vocabulary. Moreover, as an edge case, there might be terms with the same name in different vocabularies.

Do you think that we should group select options by vocabulary names? However, I don't see how we can resolve this in the case of autocomplete. Should we show an autocomplete for each vocabulary?

shelane’s picture

When using this as an exposed filter, I would not want multiple autocomplete fields. The user is going to do a search based on any of the terms with one search filter and suddenly having 5 would be a really weird UX issue.

w01f’s picture

Could we possibly use something like the Hierarchical Term Formatter to show the terms as 'parent >> child (id#)'

or:

Do something a bit more fancy like integrate functionality similar to the following modules to easily show the hierarchy when searching for terms?
Entity Reference Tree
Hierarchy Manager

I agree with shelane that having multiple autocompletes suddenly appear would be awful ux, and also that having something a bit more than just the taxonomy term id attached - example (21) - would be easier to understand and use.

claudiu.cristea’s picture

I agree with @shelane. @W01F, those widgets are looking good. However, I don't think they can be added to Drupal core.

lendude’s picture

@claudiu.cristea well spotted. For core I don't think we should do more than maybe use optgroups in the selector and only if there are multiple vocabularies selected. If people need something more fancy, they can alter the form and take it from there. How does that sound?

For the autocomplete I don't feel we need to do anything. Yes this can be confusing, but that is not something specific to views, and I don't think we should try to fix it here.

alison’s picture

Hi and thank you, everyone!

Back on July 11, we still had an 8.9.x version of this patch -- if I helped create an updated version with the latest changes, would it be supported, will there be a "backport" of this functionality, or no?

jungle’s picture

StatusFileSize
new28.94 KB
new29.73 KB
new3.5 KB

Rerolled and attaching a patch for 8.9.x

Re #121, IMO, this is applicable to 8.9.x. 9.1.x is the dev branch currently, in general, patch will be committed to 9.1.x first, and will be backported to 9.0.x and 8.9.x if applicable. So no worries, please.

jungle’s picture

StatusFileSize
new696 bytes

Forgot uploading raw-interdiff-9.1.x-115-122.txt

claudiu.cristea’s picture

@jungle, could you please post a better patch for interdiff using ‘diff -up’ or ‘git diff’ to better understand your changes? Only for 9.1.x would be enough

jungle’s picture

@claudiu.cristea, the interdiff for 9.1.x is less than 1K, so I would like to try diff -up next time (new to me). As #122 is a reroll (#115 failed to apply), I could not use git diff to make a better interdiff.

claudiu.cristea’s picture

@jungle, oh, it’s only reroll? Then there’s no need for interdiff

jungle’s picture

StatusFileSize
new29.72 KB
new2.42 KB
new29.73 KB
new856 bytes

Re #26, yes, reroll only.

Fixing CS violations and tests failed.

claudiu.cristea’s picture

claudiu.cristea’s picture

StatusFileSize
new3.49 KB
new30.55 KB
new189.04 KB

Fixed the UX issue as per #120.

Note: The vocabularies field from the extraform is a required field. If you don't select any vocabulary, the form is not submitted and this is expected, as the field is required. However, there's no error message popping-up anywhere. This is a bug and I've opened a new issue to fix that in #3163740: Validation errors of extra options form are muted.

jungle’s picture

StatusFileSize
new30.09 KB
new6.38 KB

A few generic improvements, please see the interdiff attached for details.

claudiu.cristea’s picture

No, please, all these are out-of-scope and make the patch review very hard.

jungle’s picture

Let me list what I did in #130 based on #129.

I do not think all changes are out of scope, but feel free to ignore it if you/others persist on that it makes reviewing harder.

  1. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -51,11 +61,18 @@ class TaxonomyIndexTid extends ManyToOne {
    +      @trigger_error('Calling TaxonomyIndexTid::__construct() without the $entity_repository argument is deprecated in drupal:9.1.0 and the $entity_repository argument will be required in drupal:10.0.0. See https://www.drupal.org/node/3162414', E_USER_DEPRECATED);
    

    Added __NAMESPACE__

  2. +++ b/core/modules/taxonomy/tests/src/Functional/Update/TaxonomyTermIdFilterUpdateTest.php
    @@ -0,0 +1,62 @@
    +      __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.8.0.bare.standard.php.gz',
    ...
    +    $view_as_array = Yaml::decode(file_get_contents(__DIR__ . '/../../../modules/taxonomy_test_views/test_views/views.view.test_filter_taxonomy_index_tid.yml'));
    

    replaced with dirname(__DIR__, LEVELS);

  3. +++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php
    @@ -99,6 +123,8 @@ protected function setUp($import_test_views = TRUE): void {
    +    $this->assertFieldByXpath('//select[@id="edit-options-value"]', NULL);
    

    assertFieldByXpath is deprecated. And this line looks unnecessary, so removed

  4. +++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php
    @@ -140,6 +166,78 @@ public function testFilterUI() {
    +   * Test filter UI with multiple vocabularies
    

    Should start with a verb "Test" -> "Tests"

  5. +++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php
    @@ -140,6 +166,78 @@ public function testFilterUI() {
    +    $this->assertIdentical(3, count($xpath));
    ...
    +    $this->assertIdentical(2, count($xpath));
    ...
    +    $this->assertIdentical(1, count($xpath));
    ...
    +    $this->assertIdentical(1, count($xpath));
    ...
    +    $this->assertIdentical(2, count($xpath));
    ...
    +    $this->assertIdentical(1, count($xpath));
    ...
    +    $this->assertIdentical(1, count($xpath));
    ...
    +    $this->assertIdentical(1, count($xpath));
    

    Replaced with assertCount(), a more appropriate one.

  6. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -187,7 +187,7 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
    -    if ($this->options['type'] == 'textfield') {
    +    if ($this->options['type'] === 'textfield') {
    

    Replaced with ===

claudiu.cristea’s picture

I know, but that should be fixed in other issue. Adding out-of-scope code is making hard for the reviewer to read the code.

jungle’s picture

Adding out-of-scope code is making hard for the reviewer to read the code.

Agree. But all in #132/ #130 are improving newly added code. not adding out-of-scope new code.

Sorry for all the noises here.

claudiu.cristea’s picture

@jungle, reviewers are looking to the patch (and intediff). If there are more changes then there are more diffs in the patch. A good patch is one that has minimal changes, so that the reviewer is able understand exactly how the scope of the issue has been achieved by patch. Out-of-scope changes are adding more and more diffs (noise) to the patch, making the review process harder.

lendude’s picture

Some more stuff I see:

  1. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -51,11 +61,18 @@ class TaxonomyIndexTid extends ManyToOne {
    +      @trigger_error('Calling ' . __NAMESPACE__ . '\TaxonomyIndexTid::__construct() without the $entity_repository argument is deprecated in drupal:9.1.0 and the $entity_repository argument will be required in drupal:10.0.0. See https://www.drupal.org/node/3162414', E_USER_DEPRECATED);
    

    Do we need a deprecation test for this?

  2. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -98,34 +116,28 @@ protected function defineOptions() {
               '#description' => $this->t('Select which vocabulary to show terms for in the regular options.'),
    

    should this now be plural?

  3. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -133,7 +145,10 @@ public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) {
    -      '#options' => ['select' => $this->t('Dropdown'), 'textfield' => $this->t('Autocomplete')],
    +      '#options' => [
    +        'select' => $this->t('Dropdown'),
    +        'textfield' => $this->t('Autocomplete'),
    +      ],
    

    unrelated change I think?

  4. +++ b/core/modules/taxonomy/tests/src/Functional/Update/TaxonomyTermIdFilterUpdateTest.php
    @@ -0,0 +1,62 @@
    +   * Tests that field handlers are updated properly.
    

    c/p left over, it's not a field handler here

  5. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -365,7 +388,9 @@ public function adminSummary() {
    @@ -390,8 +415,10 @@ public function getCacheContexts() {
    
    @@ -390,8 +415,10 @@ public function getCacheContexts() {
    +    foreach ($vocabularies as $vocabulary) {
    +      $dependencies[$vocabulary->getConfigDependencyKey()][] = $vocabulary->getConfigDependencyName();
    +    }
    

    Do we need test coverage for this? Probably

  6. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -400,4 +427,45 @@ public function calculateDependencies() {
    +  protected function addOption(array &$options, TermInterface $term, array $vocabularies): void {
    ...
    +    if (!empty($this->options['hierarchy']) && $this->options['limit']) {
    

    I think we are missing test coverage for what this method does. Not sure if there is existing coverage for $this->options['hierarchy'] and the - getting added

tomsaw’s picture

#127 2784233-8.9.x-127.patch Not working anymore. On Pageload i get this error:

TypeError: Argument 1 passed to Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid::Drupal\taxonomy\Plugin\views\filter\{closure}() must be an instance of Drupal\taxonomy\Plugin\views\filter\VocabularyInterface, instance of Drupal\taxonomy\Entity\Vocabulary given in Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid->Drupal\taxonomy\Plugin\views\filter\{closure}() (line 455 of /web/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php)
claudiu.cristea’s picture

StatusFileSize
new4.13 KB
new32.76 KB
  • #136.1: No, we don't test parameters additions.
  • #136.2-4: Fixed.
  • #136.5: Added test coverage. Side note: If a vocabulary is deleted, the whole view gets deleted. But this is true also with the current code, it's not something in the scope of this ticket. As a fix I would be tempted to implement DependentWithRemovalPluginInterface::onDependencyRemoval() but then I realize that removing a filter handler might be a security issue (i.e. suddenly the view shows records that should not be viewable). We need a way to go, in a follow-up.
  • #136.6: I'm not sure I get your point. What exactly do we expect to test here? And if the current code lacks coverage, isn't that coverage out-of-scope for this issue?

Status: Needs review » Needs work

The last submitted patch, 138: 2784233-138.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

claudiu.cristea’s picture

Status: Needs work » Needs review
StatusFileSize
new1.67 KB
new32.86 KB
perelesnyk’s picture

StatusFileSize
new347.88 KB

I updated the #127 8.9 patch, so it does not fail any more.

perelesnyk’s picture

Sorry, missed a couple of files. Will update in a few

tomsaw’s picture

Thanks perelesnyk :)

tomsaw’s picture

In the meanwhile i've learned one could also dispense this patch and just set multiple vids in form-preprocessing like so:

   $form['form_item_id']['#selection_settings']['target_bundles'] = ['list', 'of', 'mulitple', 'vids'];
paulocs’s picture

Status: Needs review » Needs work
StatusFileSize
new89.75 KB

Hello @claudiu.cristea,

I tested your patch and I think I found one bug. If a content type has one taxonomy term (lets say Tag1) and another content type has two taxonomy terms (Tag1 and Term new vocabulary) and I create a filter for it, the filter is returning the same content type two times. The one that is returned two times is the one that has two terms from two different vocabulary.

Cheers, Paulo.

paulocs’s picture

Actually, there is an option to remove duplicate filter results. Sorry!
So patch #140 looks good to me. I'll set back to needs review.

Cheers, Paulo

paulocs’s picture

Status: Needs work » Needs review
perelesnyk’s picture

StatusFileSize
new32.92 KB

Another go for the 8.9.x patch. Hopefully it will pass

abhijith s’s picture

StatusFileSize
new11.46 KB
new11.03 KB

Patch #140 is working fine.Patch #148 can't be applied as it is showing error.
Including screenshots upon patch #140 below :
Before patch(Only single vocabulary selection allowed):
image1
After patch(Multiple vocabulary selection possible):
img2

RTBC

bserem’s picture

Patch #148 applies nicely to 8.9.6.
I re-queued the tests since the failure seems to be irrelevant to the patch.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

gauravvvv’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new20.29 KB
new7.5 KB

RTBC +1 Patch #140 works for me.
Here I am adding an before patch and after patch screenshot for reference.

catch’s picture

Category: Bug report » Feature request
Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/taxonomy/taxonomy.post_update.php
@@ -364,3 +366,19 @@ function taxonomy_post_update_configure_status_field_widget(&$sandbox = NULL) {
+
+  /** @var \Drupal\views\ViewsConfigUpdater $view_config_updater */
+  $view_config_updater = \Drupal::classResolver(ViewsConfigUpdater::class);
+  \Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'view', function (ViewEntityInterface $view) use ($view_config_updater): bool {
+    return $view_config_updater->needsTidFilterWithMultipleVocabulariesUpdate($view);
+  });
+}

The update here looks OK, but this also needs a bc layer for when configuration is supplied by a module. i.e. the same logic needs to run in a config post save. There are some other views updates that do similar for examples.

  1. +++ b/core/modules/taxonomy/config/schema/taxonomy.views.schema.yml
    @@ -120,9 +120,12 @@ views.filter.taxonomy_index_tid:
       label: 'Taxonomy term ID'
       mapping:
    -    vid:
    -      type: string
    -      label: 'Vocabulary'
    

    Also wonder if this config key needs to be deprecated rather than simply removed.

  2. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -114,34 +131,28 @@ protected function defineOptions() {
    -          '#options' => $options,
    +          '#options' => $this->getVocabularyLabels($vocabularies),
               '#description' => $this->t('Select which vocabulary to show terms for in the regular options.'),
    -          '#default_value' => $this->options['vid'],
    

    'which vocabularies'?

  3. +++ b/core/modules/taxonomy/tests/src/Functional/Update/TaxonomyTermIdFilterUpdateTest.php
    @@ -0,0 +1,62 @@
    +
    +declare(strict_types = 1);
    +
    +namespace Drupal\Tests\taxonomy\Functional\Update;
    

    Is this needed?

  4. +++ b/core/modules/taxonomy/tests/src/Functional/Update/TaxonomyTermIdFilterUpdateTest.php
    @@ -0,0 +1,62 @@
    +
    +    // Check that, prior running updates, only the legacy 'vid' key exists.
    +    $this->assertSame('tags', $view_as_config->get("{$path}.vid"));
    

    'prior to'

falco010’s picture

I am using the patch in #148 and it is working as expected. Thanks for this!

However, wouldn't it make much more sense to prefix each taxonomy term with the vocabulary? (only if you selected multiple vocabularies in the filter).
It can be easily very confusing for editors when they have the same term name in multiple vocabularies. (this does seem to happen with some of our bigger clients with quite some vocabularies).
Also, it can be much easier to find your taxonomies in a huge list with this extra vocabulary prefix addition.

Lets say I have these 2 vocabularies:
Tags
- New
- Tag 1
- Tag 2

Category
- New
- Category 1
- Category 2

Would now create this "Has taxonomy term" filter:
- New
- Tag 1
- Tag 2
- New
- Category 1
- Category 2

How would I know which "New" I selected from which Vocabulary?

Wouldn't this be better?
- "Tags - New"
- "Tags - Tag 1"
- "Tags - Tag 2"
- "Category - New"
- "Category - Category 1"
- "Category - Category 2"

If people agree with this, I could try to expand the current patch with this.

idebr’s picture

#154 Let's keep this issue scope limited so it is easier to review and get it committed. Your proposal is sound but is not strictly related to this issue, so I suggest creating a separate issue.

ptgraber’s picture

Is there anything that can address the issue of losing existing vocabulary references after the patch is applied? ie: All my views that reference vocabularies needed their vocabularies re-selected. Small price to pay for much needed functionality, I guess, but wanted ask.

shelane’s picture

#140 will no longer apply to 9.1.5. The patch needs a reroll.

gauravvvv’s picture

shelane’s picture

Status: Needs work » Needs review
StatusFileSize
new29.61 KB

Here is a re-roll. There should be no interdiff from 140 as it is just updated for the 9.2.x branch.

claudiu.cristea’s picture

MR 449 changes:

#153.1: This has been already added in #140 and is included in MR 449.
#153.1: If we need to deprecated vid, then we're doing something wrong, either wit the post-update script or with the config imported from modules fixer.
#153.2, 3, 4: Fixed.

drewble’s picture

StatusFileSize
new28.26 KB

Re-rolled patch in #148 for 9.1.6

drewble’s picture

StatusFileSize
new5.02 KB

Fixing failed PHPCS tests from #163

Status: Needs review » Needs work

The last submitted patch, 164: 2784233-9.1.x-164.patch, failed testing. View results

drewble’s picture

StatusFileSize
new36.63 KB

My apologies to all. My second patch (#164) only got the tests. Here's a complete patch for 9.1.6 and sorry for the noise.

shelane’s picture

#166 won't apply and I have a WSOD from 164.

drewble’s picture

StatusFileSize
new35.91 KB

@shelane Sorry about that. I got it this time! #166 didn't apply because a different core patch had already modified those files. Here's a patch for 9.1.6 when no other patches are applied.

kapilv’s picture

Status: Needs work » Needs review
StatusFileSize
new36.43 KB

Status: Needs review » Needs work

The last submitted patch, 169: 2784233-169.patch, failed testing. View results

vsujeetkumar’s picture

Status: Needs work » Needs review
StatusFileSize
new36.48 KB
new2.25 KB

Fixing cs issues for 9.1.x and make interdiff with #168, Please have a look and advise.

Status: Needs review » Needs work

The last submitted patch, 171: 2784233-171.patch, failed testing. View results

shelane’s picture

Issue tags: +NorthAmerica2021

Let's get some work on this and maybe get it over the finish line...

Anyone can sign up for contribution week.
https://drupalcontributions.opensocial.site/node/75

trackleft2’s picture

For the patch on comment #169, it looks like line 127 of core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php

$this->xpath('//select[@id="edit-options-value"]', NULL);

And should be something like
$this->xpath('//select[@id="edit-options-value"]', []);
or
$this->xpath('//select[@id="edit-options-value"]');

trackleft2’s picture

And for the second failure on the patch on comment #169

According to the documentation for BrowserTestBase we are using $this->submitForm() incorrectly on lines 199,200,206, and 207 of core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php

See https://api.drupal.org/api/drupal/core%21tests%21Drupal%21Tests%21Browse...

We have:


+    $edit = [
+      'options[vids][tags]' => TRUE,
+      'options[vids][tags2]' => TRUE,
+      'options[type]' => 'textfield',
+    ];
+    $this->submitForm('admin/structure/views/nojs/handler-extra/test_filter_taxonomy_index_tid/default/filter/tid', $edit, 'Apply');
+    $this->submitForm('admin/structure/views/nojs/handler/test_filter_taxonomy_index_tid/default/filter/tid', [], 'Expose filter');
+    $edit = [
+      'options[operator]' => 'and',
+      'options[value]' => '',
+      'options[reduce_duplicates]' => TRUE,
+    ];
+    $this->submitForm(NULL, $edit, 'Apply');
+    $this->submitForm(NULL, [], 'Save');

Should probably be more like

+     $form_id = 'some-form-id'
+    $edit = [
+      'options[vids][tags]' => TRUE,
+      'options[vids][tags2]' => TRUE,
+      'options[type]' => 'textfield',
+    ];
+    $this->submitForm($edit, 'Apply', $form_id);
+    $this->submitForm([], 'Expose filter', $form_id);
+    $edit = [
+      'options[operator]' => 'and',
+      'options[value]' => '',
+      'options[reduce_duplicates]' => TRUE,
+    ];
+    $this->submitForm($edit, 'Apply', $form_id);
+    $this->submitForm([], 'Save', $form_id);
kishor_kolekar’s picture

Status: Needs work » Needs review
StatusFileSize
new36.36 KB
new1.86 KB

Hey, I have tried to cover the points mentioned in #175,#174
Please review

Status: Needs review » Needs work

The last submitted patch, 176: 2784233-176.patch, failed testing. View results

shelane’s picture

So I recently applied patch #168 and when doing a release to dev, it worked for every site of our multisite until it got to the sites that were only installed last week and hadn't previously run the post update hook. This was the error reported:

 ---------- --------------- ------------- ---------------------------------- 
  Module     Update ID       Type          Description                       
 ---------- --------------- ------------- ---------------------------------- 
  taxonomy   multiple_voca   post-update   Allow multiple vocabularies for   
             bularies_filt                 views using the taxonomy term ID  
             er                            filter.                           
 ---------- --------------- ------------- ---------------------------------- 

>  [notice] Update started: taxonomy_post_update_multiple_vocabularies_filter
>  [error]  Class "ConfigEntityUpdater" does not exist. 
>  [error]  Update failed: taxonomy_post_update_multiple_vocabularies_filter 
 [error]  Update aborted by: taxonomy_post_update_multiple_vocabularies_filter 
 [error]  Finished performing updates. 
[Acquia\Blt\Robo\Tasks\DrushTask]  Exit code 1  Time 7.815s
[error]  Failed to execute database updates!

What is strange is that this happened both on our local servers and the ACE servers, yet I can't replicate the issue locally.

shelane’s picture

StatusFileSize
new32.75 KB

Several people were working on a merge request. That one is passing the tests. I was able to apply a generated patch on both the current 9.1.x branch and the 9.2.x branch. I'm uploading here to have the tests run against a patch.

shelane’s picture

Status: Needs work » Needs review
shelane’s picture

Status: Needs review » Needs work
StatusFileSize
new185.62 KB
new75.89 KB

Tests are passing, but I believe that we lost something between the previous version that was working and the lastest. If you notice in these screen shots that the vocabulary name is no longer displayed. Instead, all the terms are just put together.

Previous:
Previous

Latest:
Latest

quietone’s picture

I am a newcomer to this issue and came here to review. I started with the Issue Summary, which says there are no remaining tasks. Really? :-) I then read the last few comments, which are very informative. Thank you shelane. The comment in #179 about several people working on the MR so a patch was uploaded means I don't know which to review, the latest patch of the MR.

Tagging for an IS update.

shelane’s picture

Status: Needs work » Needs review

Comment #181 was actually from patch #168. I have retested with #179 (same as the MR version) and it is all working. I plan on doing a full write up about it tomorrow to show that this is RTBC, but I won't mark it until I can do that write-up. Right now I will mark it as NR so that maybe someone else can do a review based on 179. When I talked with @webchick at DrupalCon, she said that it needs at least 2 people to say RTBC. I think that MR and then the following patches made it unclear that things were good with the MR. I also made sure that it would work against both the latest 9.2.x and 9.1.x, which is required for a core patch.

shelane’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new55.88 KB
new114.57 KB
new183.94 KB

The current MR works for the current 9.2.x and 9.1.x branch. The working use-case on the LLNL website.

The Views exposed filters are as expected and clear:
Exposed filter settings
Exposed filter settings

The display to the end user (as demonstrated with the link above) is clean and easy.
Exposed filter End User Display

Please let me know what documentation/help may be needed for an accepted merge to core.

rudranil29’s picture

rudranil29’s picture

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

ahebrank’s picture

Version: 9.3.x-dev » 10.0.x-dev

For the grouping noted in #181, can this be optional? I'd thought from #154 that was going to be handled in a subsequent iteration, so the appearance of this feature between working D8 and working D9 versions was a surprise. I've already had a client request to revert this functionality since they don't want the UI to expose that terms are coming from different vocabularies.

jldust’s picture

Tested using patch #148 on Drupal 8.9.14 and it works great. Would love to see this feature get added into D8 as well.

daffie’s picture

Version: 10.0.x-dev » 9.3.x-dev

Would love to see this feature get added into D8 as well.

Sorry, this will not happen,

jungle’s picture

StatusFileSize
new31.85 KB
new9.95 KB

Rerolled the patch based on the patch in #179

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 191: 2784233-191.patch, failed testing. View results

jungle’s picture

Status: Needs work » Needs review
StatusFileSize
new32.67 KB
new1.17 KB
jungle’s picture

Let's get it in to the 9.3.x branch first. The patch in #193 is ready for review.

radheymkumar’s picture

StatusFileSize
new11.03 KB
new11.46 KB

#140 Patch applied successfully shared screenshot.

jungle’s picture

Thanks @radheymkumar, but i would say the screenshots in #195 do not help at all and you can not get credit by doing that in general. A manual test similar to #184 is preferred and welcome, and you can set the status to Reviewed & tested by the community (RTBC) after a successful manual test.

danflanagan8’s picture

I haven't had a chance to dig into it too much, but this patch (#193) does not work with better_exposed_filters. If I use a bef Radio/Checkboxes filter, the tid does not get used as the radio/checkbox value. The patch does seem to work for the default core exposed filter, in my case a select element.

Update: After digging in, the bef RadioButtons filter is not prepared for the nested array of options and flattens the array incorrectly. So instead of a tid getting used as the radio/checkbox value, it's a meaningless delta value that gets used. It looks like the unprepared function is BetterExposedFiltersHelper::flattenOptions()

Obviously, bef is outside of core, but if we do something that we know breaks bef, we need to make sure that the maintainers are prepared.

chetanbharambe’s picture

Assigned: Unassigned » chetanbharambe
chetanbharambe’s picture

Assigned: chetanbharambe » Unassigned
StatusFileSize
new360.24 KB
new364.46 KB

Verified and tested patch #193.
Patch applied successfully and looks good to me.

Testing Steps:
# Goto: admin/structure/views/view/taxonomy_term
# Create the filter criteria - Has taxonomy term
# Click on setting under filer criteria
# Check the Vocabulary checkboxes

Expected Results:
# User should be able to select multiple vocabularies in the taxonomy filter

Actual Results:
# Currently User is not able to select multiple vocabularies in the taxonomy filter

Looks good to me.
Need +1 RTBC

shelane’s picture

Status: Needs review » Reviewed & tested by the community

The wording in #199 doesn’t make it clear that the result with the patch is that it DOES allow multiple vocabularies as expected. Tested 193 with the new 9.2.0 release and it’s working as expected. The results are the same as what I posted in #184. I am looking forward to when this can be committed.

danflanagan8’s picture

Status: Reviewed & tested by the community » Needs work
Related issues: +#3219356: Prepare for core allowing multiple taxonomy vocabularies on exposed filter

In the interest of keeping the maintainers of better_exposed_filters up to date on this, I have created an issue on that project:

https://www.drupal.org/project/better_exposed_filters/issues/3219356

I'm still a little wary of solving this issue in a way that doesn't automatically work with such a popular project. The patch in #193 nests the terms like so:

[
  'Vocab 1' => ['1', '6', '11'],
  'Vocab 2' => ['16', '21', '26'],
]

Is there a good reason that the options aren't simply the array of target ids? [1, 6, 11, 16, 21, 26]

Also, it's strange to me that we would be using the name of the vocabulary instead of the machine name of the vocabulary. I could break this by having two vocabularies with the same human readable name.

I'm going to set this back to Needs Work because the structure of the options array needs to be revisited.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

vikashsoni’s picture

Patch #193 not applying in drupal-9.3.x-dev showing error while going to apply

Checking patch core/modules/node/src/Plugin/views/wizard/Node.php...
Hunk #1 succeeded at 175 (offset 8 lines).
Checking patch core/modules/taxonomy/config/schema/taxonomy.views.schema.yml...
Checking patch core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php...
Checking patch core/modules/taxonomy/taxonomy.post_update.php...
error: while searching for:
'taxonomy_post_update_configure_status_field_widget' => '9.0.0',
];
}

error: patch failed: core/modules/taxonomy/taxonomy.post_update.php:18
error: core/modules/taxonomy/taxonomy.post_update.php: patch does not apply
Checking patch core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_filter_taxonomy_index_tid.yml...
Checking patch core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_filter_taxonomy_index_tid__non_existing_dependency.yml...
Checking patch core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_filter_taxonomy_index_tid_depth.yml...
Checking patch core/modules/taxonomy/tests/src/Functional/Update/TaxonomyTermIdFilterUpdateTest.php...
Checking patch core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php...
Checking patch core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyIndexTidFilterTest.php...
Checking patch core/modules/views/src/ViewsConfigUpdater.php...
error: while searching for:
if ($this->processMultivalueBaseFieldHandler($handler, $handler_type, $key, $display_id, $view)) {
$changed = TRUE;
}
return $changed;
});
}

error: patch failed: core/modules/views/src/ViewsConfigUpdater.php:138
error: core/modules/views/src/ViewsConfigUpdater.php: patch does not apply
Checking patch core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_form_checkboxes.yml...

zerogravity86’s picture

What is the status on this for Drupal 9? There seems to be a merge conflict for 9.4? Is there anyone currently and actively working on this?
Is there a chance this can be added to the core? It is such an important feature.

joachim’s picture

I agree with #201 - I don't see a reason for the nesting, since term IDs are unique across vocabularies.

Also:

  1. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -65,8 +74,10 @@ class TaxonomyIndexTid extends ManyToOne {
    -  public function __construct(array $configuration, $plugin_id, $plugin_definition, VocabularyStorageInterface $vocabulary_storage, TermStorageInterface $term_storage, AccountInterface $current_user = NULL) {
    +  public function __construct(array $configuration, $plugin_id, $plugin_definition, VocabularyStorageInterface $vocabulary_storage, TermStorageInterface $term_storage, AccountInterface $current_user = NULL, EntityRepositoryInterface $entity_repository = NULL) {
    

    Unrelated fix.

  2. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -118,34 +135,28 @@ protected function defineOptions() {
    -    $vocabularies = $this->vocabularyStorage->loadMultiple();
    -    $options = [];
    -    foreach ($vocabularies as $voc) {
    -      $options[$voc->id()] = $voc->label();
    -    }
    -
         if ($this->options['limit']) {
           // We only do this when the form is displayed.
    -      if (empty($this->options['vid'])) {
    -        $first_vocabulary = reset($vocabularies);
    -        $this->options['vid'] = $first_vocabulary->id();
    -      }
    -
    +      $vocabularies = $this->vocabularyStorage->loadMultiple();
           if (empty($this->definition['vocabulary'])) {
    

    This isn't respecting the settings on the field. It's showing ALL the vocabularies, but it should show only the vocabularies that the reference field allows.

    Although the current behaviour shows radios for ALL vocabs as well, which is wrong too. Either taxonomy_field_views_data_alter() needs to set some options, or TaxonomyIndexTid needs to inspect the field settings.

  3. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -169,19 +180,32 @@ public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) {
    +      $terms = $this->value ? $this->termStorage->loadMultiple($this->value) : [];
    

    Unrelated fix.

The fixes to properly inject a service and use entity storage to load terms are both good, but they add noise to this patch which is already fairly complicated. They should be done in a separate issue instead.

joachim’s picture

I've rebased the MR's branch on 9.4.x, and also tried to make sense of the latest patch and the MR -- it turns out they're identical (almost -- one moved line in a test class which makes no difference, and which could actually be caused by my rebase conflict resolution).

Could we agree to stick to the MR for ongoing work, to avoid confusion? (Patches are fine for people doing backports for projects to apply to their codebases.)

joachim’s picture

Still todo: deal with the feedback in #201.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

evac9’s picture

Thanks for all the patches but the most recent one #193 does not appear to be applied on 9.4.0. Anyone might have a reroll already? Thanks!

bdalomgir’s picture

I have applied #193 before which was working perfectly, but in 9.4.x its not working. Anyone planned to work on that? Thanks in advance!

ahebrank’s picture

StatusFileSize
new32.44 KB

Here's a reroll of 193 for 9.4.x, which looks like it works for 9.4.0 and 9.4.1. I get a test failure locally for the UI test but want to see what the testbot says.

The MR target needs be updated to 9.4 or 9.5 for it to be readable. Right now it's set for 9.2.

ahebrank’s picture

StatusFileSize
new32.43 KB

Attempting to fix the codesniffer failure in 211.

shelane’s picture

As much as I’d love to have this fixed in core, it doesn’t look like that is going to be happening any time soon. And now I’m unable to move to Drupal 9.4 (and there will likely be another blocker for D10). Anyone have any thoughts of making a stand alone module for this? We did this in custom code for D7 and have a sandbox project for it on d.o but never advanced it beyond that.

danflanagan8’s picture

@shelane, I would think the modified filter plugin (TaxonomyIndexTid) could be renamed and moved into its own contrib module fairly easily.

johnpitcairn’s picture

@shelane: The patch at #212 does work and can be used. It just won't pass tests.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

jungle’s picture

Status: Needs work » Needs review
StatusFileSize
new33.25 KB
new4.57 KB

Trying to fix failed tests in #212

  1. +++ b/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_taxonomy_exposed_grouped_filter.yml
    @@ -212,7 +212,7 @@ display:
    -          vid: tags
    +          vids: {  }
    

    Fix `Schema key views.view.test_taxonomy_exposed_grouped_filter:display.default.display_options.filters.field_views_testing_tags_target_id.vid failed with: missing schema`

  2. +++ b/core/modules/taxonomy/tests/src/Functional/Update/TaxonomyTermIdFilterUpdateTest.php
    @@ -30,6 +30,7 @@ protected function setDatabaseDumpFiles(): void {
    +    $view_as_array['uuid'] = \Drupal::service('uuid')->generate();
    

    Missing `uuid` in the view raised `Exception: Deprecated function: mb_strtolower(): Passing null to parameter #1 ($string) of type string is deprecated`

  3. +++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php
    @@ -206,34 +206,34 @@ public function testFilterUIWithMultipleVocabularies() {
    -    $xpath = $this->xpath('//div[@class="view-content"]//a');
    ...
    +    $xpath = $this->xpath('//div[@class="views-row"]//a');
    .
    

    class view-content does not exist anymore, replaced it with class views-row

Status: Needs review » Needs work

The last submitted patch, 217: 2784233-217.patch, failed testing. View results

jungle’s picture

StatusFileSize
new33.26 KB
new809 bytes

Fix failed TaxonomyIndexTidUiTest::testExposedGroupedFilter in #217, NW for fixing Drupal\Tests\views\Functional\Update\ViewsMultiValueFieldUpdateTest::testViewsPostUpdateFieldNamesForMultiValueFields

ameymudras’s picture

Status: Needs work » Needs review
StatusFileSize
new30.99 KB

Adding a patch for D 10.1.x

bebalachandra’s picture

Status: Needs review » Needs work
StatusFileSize
new48.76 KB

Found same issue in d10.1.x. There is no patch is available for d 10.1.x.
changing status to needs work

pradhumanjain2311’s picture

Status: Needs work » Needs review
StatusFileSize
new31.01 KB
new626 bytes

Fix PHPStan in patch #220.

pradhumanjain2311’s picture

StatusFileSize
new31.02 KB
new3.75 KB

Status: Needs review » Needs work

The last submitted patch, 223: 2784233-223.patch, failed testing. View results

jungle’s picture

Status: Needs work » Needs review
StatusFileSize
new5.88 KB
new31.81 KB

Rerolled from my previous patch in #219.

jungle’s picture

jungle’s picture

StatusFileSize
new31.71 KB
new1.89 KB

Fix CS violations

Status: Needs review » Needs work

The last submitted patch, 227: 2784233-227.patch, failed testing. View results

jungle’s picture

StatusFileSize
new32.81 KB
new3.75 KB

NW still.

jungle’s picture

StatusFileSize
new33.05 KB
new1.76 KB

Drupal\Tests\taxonomy\Functional\Update\TaxonomyTermIdFilterUpdateTest::testPostUpdateTaxonomyIndexFilterMultipleVocabularies
There should be no errors in configuration 'views.view.test_filter_taxonomy_index_tid'. Errors:
Schema key views.view.test_filter_taxonomy_index_tid:display.default.display_options.filters.tid.vid failed with: missing schema

Failed asserting that Array &0 (
'views.view.test_filter_taxonomy_index_tid:display.default.display_options.filters.tid.vid' => 'missing schema'
) is true.

This can be fixed by the following:

+  /**
+   * {@inheritdoc}
+   */
+  protected function getConfigSchemaExclusions() {
+    return ['views.view.test_filter_taxonomy_index_tid'];
+  }

But testPostUpdateTaxonomyIndexFilterMultipleVocabularies still fails. Attaching a new patch for who can help or continue.

jungle’s picture

Status: Needs work » Needs review
StatusFileSize
new31.99 KB
new3.32 KB
+++ b/core/modules/views/src/ViewsConfigUpdater.php
@@ -260,8 +260,45 @@ protected function processOembedEagerLoadFieldHandler(array &$handler, string $h
+    return $this->processDisplayHandlers($view, TRUE, function (array &$handler, string $handler_type): bool {

Finally fixed the test by changing the 2nd parameter from TRUE to FALSE

jungle’s picture

StatusFileSize
new30.97 KB
new5.21 KB
+++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
@@ -65,12 +67,18 @@ class TaxonomyIndexTid extends ManyToOne {
+  public function __construct(array $configuration, $plugin_id, $plugin_definition, VocabularyStorageInterface $vocabulary_storage, TermStorageInterface $term_storage, AccountInterface $current_user, protected ?EntityRepositoryInterface $entityRepository = NULL) {
...
+      @trigger_error('Calling ' . __METHOD__ . '() without the $entityRepository argument is deprecated in drupal:10.1.0 and is required in drupal:11.0.0. See https://www.drupal.org/node/3162414', E_USER_DEPRECATED);

Removed the injected service here to make this patch easier to review. Also, fixed failed tests introduced in #231

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs change record updates

Change record needs updating. Talks about removing something in D10 for something I don't know is deprecated anymore? Didn't see it.

jungle’s picture

Status: Needs work » Needs review
Issue tags: -Needs change record updates

As a side effect, the taxonomy_index_tid views filter plugin class should be instantiated by passing an additional $entity_repository parameter. Not passing this parameter is deprecated and will be removed in Drupal 10.0.0.

Removed the above from the CR, and the related code was removed in #232 for easier review. This one is optional, which can be done in a child issue of #2729597: [meta] Replace \Drupal with injected services where appropriate in core

gauravvvv’s picture

lendude’s picture

Status: Needs review » Reviewed & tested by the community

Been a while since I last looked at this. Went through it again, looks good, follow ups make sense.

I think the test coverage is sufficient, but not very extensive. The only thing I can think of that feels missing is the actual testing of the UI when selecting, but the current implementation doesn't have that either, so doesn't feel like it is mandatory, but others might not agree.

jungle’s picture

StatusFileSize
new661 bytes
new30.97 KB

Thanks @Lendude. Let's see how it goes.

+++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php
@@ -144,6 +165,80 @@ public function testFilterUI() {
+   * Test filter UI with multiple vocabularies.

Should start with "Tests", changing it to "Tests the filter UI with multiple vocabularies.", Keep RTBC.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 238: 2784233-238.patch, failed testing. View results

jungle’s picture

Status: Needs work » Reviewed & tested by the community

1) Drupal\Tests\ckeditor5\FunctionalJavascript\MediaTest::testLinkManualDecorator with data set "restricted" (false)

Behat\Mink\Exception\ElementNotFoundException: Element matching css ".ck-balloon-panel_visible .ck-balloon-rotator__content > .ck.ck-link-actions" not found.

It seems irrelevant. Queued another test.

Mukesh1812’s picture

@jungle Given patch #238 is not working for version 10.0.x.

larowlan’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/taxonomy/config/schema/taxonomy.views.schema.yml
    +++ b/core/modules/taxonomy/config/schema/taxonomy.views.schema.yml
    @@ -120,9 +120,12 @@ views.filter.taxonomy_index_tid:
    

    There are at least two contrib projects which reference this schema - https://git.drupalcode.org/search?group_id=2&scope=blobs&search=type:%20...

    If we make this change, their data/schema is now invalid.

    Should we instead be deprecating views.filter.taxonomy_index_tid and adding a new schema type? or leaving vid behind and deprecating it?

    I even wonder if we should be adding a new plugin here, leaving the old one and deprecating it, so we don't break contrib and N other custom plugins people will have written that extend this one.

  2. +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
    @@ -185,30 +193,26 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
    +              return $term->isPublished() || $this->currentUser->hasPermission('administer taxonomy');
    

    Shouldn't this just be using $term->access('view label')?

  3. +++ b/core/modules/views/src/ViewsConfigUpdater.php
    @@ -260,8 +260,45 @@ protected function processOembedEagerLoadFieldHandler(array &$handler, string $h
    +    if ($this->processTidFilterWithMultipleVocabulariesHandler($handler, $handler_type)) {
    +      $changed = TRUE;
    +    }
    

    this hunk looks to be in the wrong spot now, shouldn't it be inside ::updateAll?

jungle’s picture

  1. Re #241, per a quick manual testing made yesterday, the vid key was still there after running the database update.. #242.1 may be relevant.
  2. +++ b/core/modules/taxonomy/taxonomy.post_update.php
    --- a/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_filter_taxonomy_index_tid.yml
    +++ b/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_filter_taxonomy_index_tid.yml
    

    Meanwhile, found that the view exported is outdated. Maybe a follow-up to update them as they were not introduced by this issue -- out of scope here.

  3. diff --git a/core/modules/taxonomy/config/schema/taxonomy.views.schema.yml b/core/modules/taxonomy/config/schema/taxonomy.views.schema.yml
    index 9ec9758185..398b7a130b 100644
    --- a/core/modules/taxonomy/config/schema/taxonomy.views.schema.yml
    +++ b/core/modules/taxonomy/config/schema/taxonomy.views.schema.yml
    @@ -116,9 +116,36 @@ views.field.taxonomy_index_tid:
             type: string
             label: 'Vocabulary'
     
    +views.filter.taxonomy_index_tid_vids:
    +  type: views.filter.many_to_one
    +  label: 'Taxonomy term ID'
    +  mapping:
    +    vid:
    +      type: string
    +      label: 'Vocabulary'
    +    type:
    +      type: string
    +      label: 'Selection type'
    +    hierarchy:
    +      type: boolean
    +      label: 'Show hierarchy in dropdown'
    +    limit:
    +      type: boolean
    +      label: 'Limit to vocabulary'
    +    error_message:
    +      type: boolean
    +      label: 'Display error message'
    +    value:
    +      type: sequence
    +      label: 'Values'
    +      sequence:
    +        type: integer
    +        label: 'Value'
    +
     views.filter.taxonomy_index_tid:
       type: views.filter.many_to_one
       label: 'Taxonomy term ID'
    +  deprecated: "The 'views.filter.taxonomy_index_tid' config schema is deprecated in drupal:10.0.0 and is removed from drupal:11.0.0. Use the 'views.filter.taxonomy_index_tid_vids' config schema instead. See https://www.drupal.org/node/3162414."
       mapping:
         vid:
           type: string
    

    Can we agree on #242.1 to add a new plugin, e.g. name it taxonomy_index_tid_vids with the new schema above and continue?

Thanks, @Lendude for your review.

jungle’s picture

Status: Needs work » Needs review

MR !3582 added a new filter plugin and intended to deprecate the filter plugin taxonomy_index_tid, because there are usages of taxonomy_index_tid in contrib modules pointed by @larowlan in #242.1.

function taxonomy_field_views_data_alter(array &$data, FieldStorageConfigInterface $field_storage) {
  if ($field_storage->getType() == 'entity_reference' && $field_storage->getSetting('target_type') == 'taxonomy_term') {
    foreach ($data as $table_name => $table_data) {
      foreach ($table_data as $field_name => $field_data) {
        if (isset($field_data['filter']) && $field_name != 'delta') {
          $data[$table_name][$field_name]['filter']['id'] = 'taxonomy_index_tid';
        }
      }
    }
  }
}

BUT we can only have one filter in use. The two filters can't coexist well. See the code above in taxonomy.views.inc

So, MR !3681 was opened, which added the vids key to the schema but kept the vid key as deprecated.

All points from #242 were addressed in MR !3681

CR updated

MR !3681 is ready for review.

jungle’s picture

Issue summary: View changes

Updating IS

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Functionality wise I still appear to be able to select multiple taxonomies

Deprecation appears to be added per #242

Reading 247 the solution makes sense to me since we can only have 1. Marking this for committer review again.

quietone’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs change record updates

I was searching the Draft change records and see that this one has the wrong branch and version. Tagging for an update. Does anything else need to be changed in the CR?

smustgrave’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs change record updates

Think the CR catches the bulk of what is happening in being able to use multiple taxonomies now.

Updated the branch for 10.1.x but feel it will be 10.2.x in a few days.

claudiu.cristea’s picture

Status: Reviewed & tested by the community » Needs work

See my remark in MR

Rassoni made their first commit to this issue’s fork.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

jaydip makawana’s picture

StatusFileSize
new39.72 KB

I have re-roll the patch for 9.5.x from MR 3681 (https://git.drupalcode.org/project/drupal/-/merge_requests/3681)

jaydip makawana’s picture

StatusFileSize
new39.72 KB

fixed the mistake I made in previous patch.

I have re-roll the patch for 9.5.x from MR 3681 (https://git.drupalcode.org/project/drupal/-/merge_requests/3681)

jaydip makawana’s picture

StatusFileSize
new39.7 KB

I have re-roll the patch for D10.1.1 from MR 3681

jklmnop’s picture

Patch in #257 is rejected when applied to Drupal 10.2.0. I could try to reroll it myself, but I'm afraid I might not know exactly what this code is meant to do.

The reason is in `web/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php`. The `*.rej` file reads as follows:

--- modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
+++ modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
@@ -160,19 +155,32 @@ public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) {
     ];
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function submitExtraOptionsForm($form, FormStateInterface $form_state) {
+    $vids = $form_state->getValue(['options', 'vids']);
+    $form_state->setValue(['options', 'vids'], array_keys(array_filter($vids)));
+  }
+
   protected function valueForm(&$form, FormStateInterface $form_state) {
-    $vocabulary = $this->vocabularyStorage->load($this->options['vid']);
-    if (empty($vocabulary) && $this->options['limit']) {
+    $vocabularies = $this->vocabularyStorage->loadMultiple($this->options['vids']);
+    if (empty($vocabularies) && $this->options['limit']) {
       $form['markup'] = [
-        '#markup' => '<div class="js-form-item form-item">' . $this->t('An invalid vocabulary is selected. Please change it in the options.') . '</div>',
+        '#markup' => '<div class="js-form-item form-item">' . $this->t('Invalid or no vocabularies are selected. Please select valid vocabularies in filter settings.') . '</div>',
       ];
       return;
     }
 
+    $form['value'] = [
+      '#title' => $this->options['limit'] ? $this->formatPlural(count($vocabularies), 'Select terms from vocabulary @vocabs', 'Select terms from vocabularies @vocabs', [
+        '@vocabs' => "'" . implode("', '", $this->getVocabularyLabels($vocabularies)) . "'",
+      ]) : $this->t('Select terms'),
+    ];
+
     if ($this->options['type'] == 'textfield') {
-      $terms = $this->value ? Term::loadMultiple(($this->value)) : [];
-      $form['value'] = [
-        '#title' => $this->options['limit'] ? $this->t('Select terms from vocabulary @voc', ['@voc' => $vocabulary->label()]) : $this->t('Select terms'),
+      $terms = $this->value ? $this->termStorage->loadMultiple($this->value) : [];
+      $form['value'] += [
         '#type' => 'textfield',
         '#default_value' => EntityAutocomplete::getEntityLabels($terms),
       ];

alt.dev made their first commit to this issue’s fork.

alt.dev’s picture

StatusFileSize
new47.13 KB

I created a new branch and re-rolled code to the 10.2.x. core branch.

Attaching the re-rolled patch for the Drupal 10.2.0 version(taken from the new MR !6023)

charlliequadros’s picture

StatusFileSize
new39.57 KB

As mentioned on #258 the patch from #257 can't be applied to Drupal 10.2, therefore I created a new patch for it.

johnpitcairn’s picture

#261 and #262 will not apply to 10.2.x, needs a reroll.

evac9’s picture

StatusFileSize
new39.5 KB

It looks like /core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTermFilterDepthTest.php was removed from core 10.2.3 so I created a patch by removing the diffs pertaining to that file from #262 to see if it helps.

joaopauloc.dev’s picture

patch #264(2784233-264-from-262.patch) worked for me in D 10.2.4.
thanks

ershov.andrey’s picture

StatusFileSize
new36.15 KB

Updated patch for 10.2.6

Carlos Romero made their first commit to this issue’s fork.

COBadger made their first commit to this issue’s fork.

andreastkdf made their first commit to this issue’s fork.

tikaszvince’s picture

StatusFileSize
new38.65 KB

Updated patch for 10.3.1

joegraduate made their first commit to this issue’s fork.

trackleft2’s picture

Since MR !3681 changes these test_views do we think that the deprecation message should be expected in core/modules/views/tests/src/Kernel/TestViewsTest.php

  • core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_filter_taxonomy_index_tid.yml
  • core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_filter_taxonomy_index_tid__non_existing_dependency.yml
  • core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_filter_taxonomy_index_tid_depth.yml
  • core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_taxonomy_exposed_grouped_filter.yml

Here is the failure I am referring to:

---- Drupal\Tests\views\Kernel\TestViewsTest ----
Status    Group      Filename          Line Function                            
--------------------------------------------------------------------------------
Fail      Other      phpunit-149.xml      0 Drupal\Tests\views\Kernel\TestViews
    PHPUnit Test failed to complete; Error: PHPUnit 10.5.35 by Sebastian
    Bergmann and contributors.
    
    Runtime:       PHP 8.3.12
    Configuration: /builds/issue/drupal-2784233/core/phpunit.xml.dist
    
    F                                                                   1 / 1
    (100%)
    
    Time: 00:08.355, Memory: 10.00 MB
    
    There was 1 failure:
    
    1) Drupal\Tests\views\Kernel\TestViewsTest::testDefaultConfig
    Failed asserting that string matches format description.
    --- Expected
    +++ Actual
    @@ @@
     @expectedDeprecation:
    -%A  The 'vid' key in 'views.filter.taxonomy_index_tid' config schema is
    deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Update your
    view to use the 'vids' key instead. See https://www.drupal.org/node/3162414
    -  Method "Twig\Extension\ExtensionInterface::getFunctions()" might add
    "array" as a native return type declaration in the future. Do the same in
    implementation "Drupal\Core\Template\TwigExtension" now to avoid errors or
    add an explicit @return annotation to suppress this message.
    +  The "Twig\Environment::getTemplateClass()" method is considered
    internal. It may change without further notice. You should not extend it
    from "Drupal\Core\Template\TwigEnvironment".
    +  Method "Twig\Extension\ExtensionInterface::getFunctions()" might add
    "array" as a native return type declaration in the future. Do the same in
    implementation "Drupal\Core\Template\TwigExtension" now to avoid errors or
    add an explicit @return annotation to suppress this message.
    +  Method "Twig\Extension\ExtensionInterface::getFilters()" might add
    "array" as a native return type declaration in the future. Do the same in
    implementation "Drupal\Core\Template\TwigExtension" now to avoid errors or
    add an explicit @return annotation to suppress this message.
    +  Method "Twig\Extension\ExtensionInterface::getNodeVisitors()" might add
    "array" as a native return type declaration in the future. Do the same in
    implementation "Drupal\Core\Template\TwigExtension" now to avoid errors or
    add an explicit @return annotation to suppress this message.
    +  Method "Twig\Extension\ExtensionInterface::getTokenParsers()" might add
    "array" as a native return type declaration in the future. Do the same in
    implementation "Drupal\Core\Template\TwigExtension" now to avoid errors or
    add an explicit @return annotation to suppress this message.
    +  Method "Twig\Loader\FilesystemLoader::findTemplate()" might add
    "?string" as a native return type declaration in the future. Do the same in
    child class "Drupal\Core\Template\Loader\FilesystemLoader" now to avoid
    errors or add an explicit @return annotation to suppress this message.
    +  Method "Twig\Loader\LoaderInterface::exists()" might add "bool" as a
    native return type declaration in the future. Do the same in implementation
    "Drupal\Core\Template\Loader\StringLoader" now to avoid errors or add an
    explicit @return annotation to suppress this message.
    +  Method "Doctrine\Common\Annotations\Reader::getClassAnnotations()" might
    add "array" as a native return type declaration in the future. Do the same
    in implementation
    "Drupal\Component\Annotation\Doctrine\SimpleAnnotationReader" now to avoid
    errors or add an explicit @return annotation to suppress this message.
    +  Method "Doctrine\Common\Annotations\Reader::getMethodAnnotations()"
    might add "array" as a native return type declaration in the future. Do the
    same in implementation
    "Drupal\Component\Annotation\Doctrine\SimpleAnnotationReader" now to avoid
    errors or add an explicit @return annotation to suppress this message.
    +  Method "Doctrine\Common\Annotations\Reader::getPropertyAnnotations()"
    might add "array" as a native return type declaration in the future. Do the
    same in implementation
    "Drupal\Component\Annotation\Doctrine\SimpleAnnotationReader" now to avoid
    errors or add an explicit @return annotation to suppress this message.
    +  Method "Doctrine\Common\Annotations\Reader::getClassAnnotation()" might
    add "?T" as a native return type declaration in the future. Do the same in
    implementation
    "Drupal\Component\Annotation\Doctrine\SimpleAnnotationReader" now to avoid
    errors or add an explicit @return annotation to suppress this message.
    +  Method "Doctrine\Common\Annotations\Reader::getMethodAnnotation()" might
    add "?T" as a native return type declaration in the future. Do the same in
    implementation
"Drupal\Component\Annotation\Doctrine\SimpleAnnotationReader" now to avoid
errors or add an explicit @return annotation to suppress this message.
+  Method "Doctrine\Common\Annotations\Reader::getPropertyAnnotation()"
might add "?T" as a native return type declaration in the future. Do the
same in implementation
"Drupal\Component\Annotation\Doctrine\SimpleAnnotationReader" now to avoid
errors or add an explicit @return annotation to suppress this message.
/builds/issue/drupal-2784233/core/tests/Drupal/TestTools/Extension/DeprecationBridge/ExpectDeprecationTrait.php:78
FAILURES!
Tests: 1, Assertions: 284, Failures: 1.

trackleft2’s picture

We should still consider @larowlan's suggestion to deprecate the existing plugin and create a new plugin with this functionality. Seehttps://www.drupal.org/project/drupal/issues/2784233#comment-14949645

This makes even more sense now that #3347343: Add Views EntityReference filter to support better UX for exposed filters has landed with the follow-up #3339738: Convert TaxonomyIndexTid to use new EntityReference filter

At any rate, I've updated two merge requests on this issue. One that targets the 10.1.x branch of Drupal, and another that targets the 11.x branch.

trackleft2’s picture

Status: Needs work » Needs review
needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

bfuzze9898’s picture

Patch #270 is working for me on 10.3.10. Thanks.

hmdnawaz made their first commit to this issue’s fork.

hmdnawaz changed the visibility of the branch 11.x-2784233-multiple-vocabularies-deprecated-vid to hidden.

netboss’s picture

I can also confirm that patch #270 is working for me on 10.4.5. Thank you.

bboty’s picture

Patch #270 works for me as well (previously mistakenly wrote it didn't but it was by my mistake, actually).

tikaszvince’s picture

StatusFileSize
new45.13 KB

Reroll MR2784233 patch for 11.2.x / 11.x latest

tikaszvince’s picture

StatusFileSize
new42.05 KB

Reroll MR2784233 patch for 11.3.x / 11.x latest

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

hmdnawaz’s picture

StatusFileSize
new41.98 KB

Patch in #284 produces an error

Error: Call to a member function id() on null in Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid->valueForm() (line 205 of core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php).

Because of a missing line in the patch.

Here is the correct one for 11.3.3