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.
| Comment | File | Size | Author |
|---|---|---|---|
| #286 | 2784233-286.patch | 41.98 KB | hmdnawaz |
| #284 | 2784233-11.3.x.patch | 42.05 KB | tikaszvince |
| #283 | 2784233-11.x.patch | 45.13 KB | tikaszvince |
| #276 | 2784233-nr-bot.txt | 90 bytes | needs-review-queue-bot |
| #270 | 2784233-270.patch | 38.65 KB | tikaszvince |
Issue fork drupal-2784233
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:
- 2784233-multiple-vocabularies
changes, plain diff MR !3582
- 11.1.x-2784233-multiple-vocabularies-deprecated-vid
changes, plain diff MR !11313
- 2784233-multiple-vocabularies-deprecated-vid
changes, plain diff MR !3681
- drupal-2784233-2784233-multiple-vocabularies-deprecated-vid-10.2.x
changes, plain diff MR !6023
- 2784233-multi-vocab
changes, plain diff MR !449
- 11.x
compare
- 9.2.x
compare
- 10.2.x
compare
- 10.1.x
compare
- 11.x-2784233-multiple-vocabularies-deprecated-vid
changes, plain diff MR !10425
- 9.1.x
changes, plain diff MR !386
Comments
Comment #2
dawehnerHere is a start for this bug
Comment #3
dawehnerComment #4
lendudeYeah this change makes sense.
Currently looks like this:

Couple of things
this can be removed I'd say
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.
Comment #5
dawehnerHere is an update path, a test and an update path test.
Comment #7
dawehnerJust fixed it.
Comment #8
lendudeLooking good. Couple of things I see:
'vid' should now be redundant so we should remove it
Any reason for not allowing this other then 'limited use-case' (large lists in select == bad idea)?
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"
copy/paste leftover? 'is using vids' or something.
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.
copy/paste leftover, needs update.
Comment #9
dawehnerThank you @lendude for the review!
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?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.
Good catch!
Sure, let's go with that.
Comment #10
claudiu.cristeaWeird that we keep the array() syntax on the outer array while using the square bracket syntax on the inner array :)
Extra empty line.
Comment #11
dawehnerThank you for your review @claudiu.cristea!
Sure, let's fix that.
Comment #14
claudiu.cristealet's see
Comment #15
dawehnerThank you @claudiu.cristea!
What are your other thoughts about this particular patch?
Comment #16
claudiu.cristea@dawehner, well, it looks good to me and I think it makes sense. I did some cleanup, improved the update path test, nits, etc.
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.
Comment #17
claudiu.cristeaEven more cleanup.
Comment #18
dawehnerGood point!
Good point
Why do we have to do that? This particular view should not have tid stuff in the first place.
Comment #19
claudiu.cristea@dawehner, if we put
vid: tags(the old schema) directly in the .yml thenDrupal\Tests\views\Kernel\TestViewsTest::testDefaultConfig()fails: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.
Comment #22
claudiu.cristeaComment #23
dawehnerAh 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
Comment #25
claudiu.cristeaComment #26
lendudeLooks 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.
Comment #27
jacineI'd just like to chime in to say I've been testing this patch and it all (finally) works as advertised. Thank you!
Comment #28
catchWhat happens if you have a module providing default config after this change (if they don't update it)?
Comment #29
dawehnerMh, 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.
Comment #30
catchYes 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.
Comment #31
dawehnerIs there some form of event which is just fired on config import?
Comment #32
lendudeTook a stab at this with an
EventSubscriberfired onConfigEvents::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
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
Comment #33
claudiu.cristeaComment #34
claudiu.cristeaRepost patch from #32.
Comment #36
dawehnerIMHO 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_insertseems to be a good approach to solve the problem. Thoughts?Comment #37
lendude@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:
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?
Comment #38
catchI 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.
Comment #39
dawehnerI 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?
Comment #40
lendude@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).
Comment #41
dawehnerWhat about simply adding the same logic on here again?
Comment #44
edwardchiapetAttached is a reroll of the patch for 8.3.1.
Comment #45
kbasarab commentedHere 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.
Comment #47
gpap commented[deleted]
Comment #48
lendudeComment #52
tomsaw commentedI'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?
Comment #53
otherl commentedReroll for 8.5.1.
Comment #55
kennethos commentedMade 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.
Comment #56
kennethos commentedReroll against 8.5.x
Comment #57
manish-31 commented@kennethos patch #56 failed for 8.7.x-dev.
Comment #58
gpap commented[deleted]
Comment #59
rudranil29 commentedreturn $vocabulary->label();q
q is removed. from patch
Comment #61
ahebrank commentedRerolled 57 to apply to 8.6 / 8.7. I'm using with 8.6.2 and seems to be working so far.
Comment #62
ahebrank commentedThis might fix the schema test errors.
Comment #63
ahebrank commentedChipping away at test errors. This adds a cast in the checkboxes render element that might be out of scope for this.
Comment #64
ahebrank commentedRemoving some cruft and no longer messing with render elements. Local tests look good, so fingers crossed.
Comment #65
ahebrank commentedOK, one more -- found a node Views UI wizard using the old vocab config.
Comment #66
gpap commented[deleted]
Comment #67
Paulset commentedSomeone for this important feature ?
I have version 8.6 of Drupal and for the moment the patch have not passed validation
Comment #68
ahebrank commented65 should work for 8.6.10, so I'm going to hide 66 since it doesn't apply.
Comment #70
tomsaw commented#65 fails for new Drupal 8.7.0 core with revisioned taxonomy terms
Comment #71
ahebrank commentedReroll for 8.7.x.
Comment #72
tomsaw commentedThanks a lot ahebrank, #71 Works !
One thing: Git moaned about trailing whitespace @line 528
Comment #73
ahebrank commentedFixing 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.
Comment #74
lendudeThe 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
Comment #75
ahebrank commentedAh, I see the regression now. Thanks.
Comment #76
ahebrank commentedComment #77
panchoThis 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.
Comment #78
yogeshmpawarComment #79
yogeshmpawarResolved some coding standard issues & added an interdiff.
Comment #80
daffie commentedComment #81
kostyashupenkoComment #82
daffie commentedPatch looks good, almost RTBC. Some minor points left for me:
I would like to see a comment why we have this piece of code here.
Why does the option vids need to be required, when the option vid was not?
Why do we add the variable $out? It is not used anywhere.
Comment #83
daffie commentedForgot a nitpick:
The test has no docblock.
Comment #85
freelockHuh. 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....
Comment #86
rensingh99 commentedHi,
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
Comment #88
jungleMade 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
2. Removed variable $out according to comment #82
Comment #90
jungleTry to fix the CI error by adding the following lines into taxonomy_post_update_taxonomy_index_filter_multiple_vocabularies()
Comment #91
vinodhini.e commentedI applied patch #90, It's working for me.
I am attaching a screenshot before and after applying the patch.
Comment #92
introfini commentedI applied patch #90, and it's also working for me.
Thanks!
Comment #93
maursilveira commentedI 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!
Comment #94
michelledarlingTested 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!
Comment #95
jungleRe #94, have you run the database update? By drush, it's
drush updbor visit/update.phpComment #96
dercheffeThat would be really a great enhancement for taxonomy 🤩.
Comment #97
rudranil29 commentedI applied patch #90, looks good to me working fine..
Comment #98
dercheffeI applied patch in #90 at simplytest.me (Drupal 8.8.5) and it's working fine for me. Please commit it. thanks.
Comment #99
lendudeWe 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.Comment #101
aleevasRe-rolled up to 9.1
Comment #102
jungleThanks, @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.
Comment #103
shelaneNeither patch 90 or 101 can be applied to 8.9.2.
Comment #104
mayurjadhav commentedcore/modules/taxonomy/taxonomy.post_update.phphas 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.
Comment #105
tanubansal commentedAfter 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
Comment #106
claudiu.cristeaAdded back the tests and used ViewsConfigUpdater. However, feels strange to put taxonomy logic in Views module.
Comment #108
claudiu.cristeaFew remarks:
This was an early BC assurance. Now we rely on ViewsConfigUpdater.
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?
This text should probably reflect that we're using more than one 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?Similarly when loading vocabularies, we should use the
taxonomy_termstorage instead ofTermShouldn't we enclose with quotes the each vocabulary label?
Why not using an
INoperator? Then we can pass all vids in only one condition.Better not touch this line. Otherwise I'm forced to request this service to be injected :)
Comment #109
claudiu.cristeaFix tests, #108, coding standards. Needs change record for introduced deprecation.
Comment #110
claudiu.cristeaOops!
Comment #111
claudiu.cristeaRerolled.
Comment #112
claudiu.cristeaentity.repositoryservice.Comment #113
claudiu.cristeaComment #114
lendudeLooks really great, just one question really:
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.
Comment #115
claudiu.cristea@Lendude
Indeed. Fixed.
I went with a different approach to resolve the code duplication.
Comment #116
claudiu.cristea@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?
Comment #117
shelaneWhen 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.
Comment #118
w01f commentedCould 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.
Comment #119
claudiu.cristeaI agree with @shelane. @W01F, those widgets are looking good. However, I don't think they can be added to Drupal core.
Comment #120
lendude@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.
Comment #121
alisonHi 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?
Comment #122
jungleRerolled 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.
Comment #123
jungleForgot uploading raw-interdiff-9.1.x-115-122.txt
Comment #124
claudiu.cristea@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
Comment #125
jungle@claudiu.cristea, the interdiff for 9.1.x is less than 1K, so I would like to try
diff -upnext time (new to me). As #122 is a reroll (#115 failed to apply), I could not usegit diffto make a better interdiff.Comment #126
claudiu.cristea@jungle, oh, it’s only reroll? Then there’s no need for interdiff
Comment #127
jungleRe #26, yes, reroll only.
Fixing CS violations and tests failed.
Comment #128
claudiu.cristeaWhile working on this, I've discovered #3163740: Validation errors of extra options form are muted
Comment #129
claudiu.cristeaFixed 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.
Comment #130
jungleA few generic improvements, please see the interdiff attached for details.
Comment #131
claudiu.cristeaNo, please, all these are out-of-scope and make the patch review very hard.
Comment #132
jungleLet 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.
Added __NAMESPACE__
replaced with dirname(__DIR__, LEVELS);
assertFieldByXpath is deprecated. And this line looks unnecessary, so removed
Should start with a verb "Test" -> "Tests"
Replaced with assertCount(), a more appropriate one.
Replaced with ===
Comment #133
claudiu.cristeaI know, but that should be fixed in other issue. Adding out-of-scope code is making hard for the reviewer to read the code.
Comment #134
jungleAgree. But all in #132/ #130 are improving newly added code. not adding out-of-scope new code.
Sorry for all the noises here.
Comment #135
claudiu.cristea@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.
Comment #136
lendudeSome more stuff I see:
Do we need a deprecation test for this?
should this now be plural?
unrelated change I think?
c/p left over, it's not a field handler here
Do we need test coverage for this? Probably
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
Comment #137
tomsaw commented#127 2784233-8.9.x-127.patch Not working anymore. On Pageload i get this error:
Comment #138
claudiu.cristeaDependentWithRemovalPluginInterface::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.Comment #140
claudiu.cristeaAccount changes from #3101738: Exposed term filters should not show term options that the user does not have access to.
Comment #141
perelesnyk commentedI updated the #127 8.9 patch, so it does not fail any more.
Comment #142
perelesnyk commentedSorry, missed a couple of files. Will update in a few
Comment #143
tomsaw commentedThanks perelesnyk :)
Comment #144
tomsaw commentedIn the meanwhile i've learned one could also dispense this patch and just set multiple vids in form-preprocessing like so:
Comment #145
paulocsHello @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.
Comment #146
paulocsActually, 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
Comment #147
paulocsComment #148
perelesnyk commentedAnother go for the 8.9.x patch. Hopefully it will pass
Comment #149
abhijith s commentedPatch #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):
After patch(Multiple vocabulary selection possible):
RTBC
Comment #150
bserem commentedPatch #148 applies nicely to 8.9.6.
I re-queued the tests since the failure seems to be irrelevant to the patch.
Comment #152
gauravvvv commentedRTBC +1 Patch #140 works for me.
Here I am adding an before patch and after patch screenshot for reference.
Comment #153
catchThe 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.
Also wonder if this config key needs to be deprecated rather than simply removed.
'which vocabularies'?
Is this needed?
'prior to'
Comment #154
falco010I 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.
Comment #155
idebr commented#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.
Comment #156
ptgraber commentedIs 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.
Comment #157
shelane#140 will no longer apply to 9.1.5. The patch needs a reroll.
Comment #158
gauravvvv commentedComment #160
shelaneHere is a re-roll. There should be no interdiff from 140 as it is just updated for the 9.2.x branch.
Comment #162
claudiu.cristeaMR 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.
Comment #163
drewble commentedRe-rolled patch in #148 for 9.1.6
Comment #164
drewble commentedFixing failed PHPCS tests from #163
Comment #166
drewble commentedMy 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.
Comment #167
shelane#166 won't apply and I have a WSOD from 164.
Comment #168
drewble commented@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.
Comment #169
kapilv commentedComment #171
vsujeetkumar commentedFixing cs issues for 9.1.x and make interdiff with #168, Please have a look and advise.
Comment #173
shelaneLet'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
Comment #174
trackleft2For 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"]');Comment #175
trackleft2And 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.phpSee https://api.drupal.org/api/drupal/core%21tests%21Drupal%21Tests%21Browse...
We have:
Should probably be more like
Comment #176
kishor_kolekar commentedHey, I have tried to cover the points mentioned in #175,#174
Please review
Comment #178
shelaneSo 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:
What is strange is that this happened both on our local servers and the ACE servers, yet I can't replicate the issue locally.
Comment #179
shelaneSeveral 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.
Comment #180
shelaneComment #181
shelaneTests 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:

Latest:

Comment #182
quietone commentedI 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.
Comment #183
shelaneComment #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.
Comment #184
shelaneThe 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:


The display to the end user (as demonstrated with the link above) is clean and easy.

Please let me know what documentation/help may be needed for an accepted merge to core.
Comment #185
rudranil29 commentedComment #186
rudranil29 commentedComment #188
ahebrank commentedFor 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.
Comment #189
jldust commentedTested using patch #148 on Drupal 8.9.14 and it works great. Would love to see this feature get added into D8 as well.
Comment #190
daffie commentedSorry, this will not happen,
Comment #191
jungleRerolled the patch based on the patch in #179
Comment #193
jungleComment #194
jungleLet's get it in to the 9.3.x branch first. The patch in #193 is ready for review.
Comment #195
radheymkumar commented#140 Patch applied successfully shared screenshot.
Comment #196
jungleThanks @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.Comment #197
danflanagan8I 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
RadioButtonsfilter 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 isBetterExposedFiltersHelper::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.
Comment #198
chetanbharambe commentedComment #199
chetanbharambe commentedVerified 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
Comment #200
shelaneThe 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.
Comment #201
danflanagan8In 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:
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.
Comment #203
vikashsoni commentedPatch #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...
Comment #204
zerogravity86 commentedWhat 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.
Comment #205
joachim commentedI agree with #201 - I don't see a reason for the nesting, since term IDs are unique across vocabularies.
Also:
Unrelated fix.
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.
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.
Comment #206
joachim commentedI'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.)
Comment #207
joachim commentedStill todo: deal with the feedback in #201.
Comment #209
evac9 commentedThanks 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!
Comment #210
bdalomgir commentedI 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!
Comment #211
ahebrank commentedHere'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.
Comment #212
ahebrank commentedAttempting to fix the codesniffer failure in 211.
Comment #213
shelaneAs 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.
Comment #214
danflanagan8@shelane, I would think the modified filter plugin (TaxonomyIndexTid) could be renamed and moved into its own contrib module fairly easily.
Comment #215
johnpitcairn commented@shelane: The patch at #212 does work and can be used. It just won't pass tests.
Comment #217
jungleTrying to fix failed tests in #212
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`
Missing `uuid` in the view raised `Exception: Deprecated function: mb_strtolower(): Passing null to parameter #1 ($string) of type string is deprecated`
class view-content does not exist anymore, replaced it with class views-row
Comment #219
jungleFix failed TaxonomyIndexTidUiTest::testExposedGroupedFilter in #217, NW for fixing Drupal\Tests\views\Functional\Update\ViewsMultiValueFieldUpdateTest::testViewsPostUpdateFieldNamesForMultiValueFields
Comment #220
ameymudras commentedAdding a patch for D 10.1.x
Comment #221
bebalachandra commentedFound same issue in d10.1.x. There is no patch is available for d 10.1.x.
changing status to needs work
Comment #222
pradhumanjain2311 commentedFix PHPStan in patch #220.
Comment #223
pradhumanjain2311 commentedComment #225
jungleRerolled from my previous patch in #219.
Comment #226
jungleComment #227
jungleFix CS violations
Comment #229
jungleNW still.
Comment #230
jungleThis can be fixed by the following:
But testPostUpdateTaxonomyIndexFilterMultipleVocabularies still fails. Attaching a new patch for who can help or continue.
Comment #231
jungleFinally fixed the test by changing the 2nd parameter from TRUE to FALSE
Comment #232
jungleRemoved the injected service here to make this patch easier to review. Also, fixed failed tests introduced in #231
Comment #233
smustgrave commentedChange record needs updating. Talks about removing something in D10 for something I don't know is deprecated anymore? Didn't see it.
Comment #234
jungleRemoved 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
Comment #235
jungleFiled #3344389: Inject entity.repository service instead of using \Drupal::service('entity.repository') in non-tests for #234
Comment #236
gauravvvv commentedComment #237
lendudeBeen 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.
Comment #238
jungleThanks @Lendude. Let's see how it goes.
Should start with "Tests", changing it to "Tests the filter UI with multiple vocabularies.", Keep RTBC.
Comment #240
jungle1) Drupal\Tests\ckeditor5\FunctionalJavascript\MediaTest::testLinkManualDecorator with data set "restricted" (false)
It seems irrelevant. Queued another test.
Comment #241
Mukesh1812 commented@jungle Given patch #238 is not working for version 10.0.x.
Comment #242
larowlanThere 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.
Shouldn't this just be using $term->access('view label')?
this hunk looks to be in the wrong spot now, shouldn't it be inside ::updateAll?
Comment #243
jungleMeanwhile, 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.
Can we agree on #242.1 to add a new plugin, e.g. name it
taxonomy_index_tid_vidswith the new schema above and continue?Thanks, @Lendude for your review.
Comment #247
jungleMR !3582 added a new filter plugin and intended to deprecate the filter plugin
taxonomy_index_tid, because there are usages oftaxonomy_index_tidin contrib modules pointed by @larowlan in #242.1.BUT we can only have one filter in use. The two filters can't coexist well. See the code above in
taxonomy.views.incSo, 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.
Comment #248
jungleUpdating IS
Comment #249
smustgrave commentedFunctionality 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.
Comment #250
quietone commentedI 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?
Comment #251
smustgrave commentedThink 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.
Comment #252
claudiu.cristeaSee my remark in MR
Comment #255
jaydip makawana commentedI have re-roll the patch for 9.5.x from MR 3681 (https://git.drupalcode.org/project/drupal/-/merge_requests/3681)
Comment #256
jaydip makawana commentedfixed 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)
Comment #257
jaydip makawana commentedI have re-roll the patch for D10.1.1 from MR 3681
Comment #258
jklmnop commentedPatch 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:
Comment #261
alt.dev commentedI 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)
Comment #262
charlliequadros commentedAs mentioned on #258 the patch from #257 can't be applied to Drupal 10.2, therefore I created a new patch for it.
Comment #263
johnpitcairn commented#261 and #262 will not apply to 10.2.x, needs a reroll.
Comment #264
evac9 commentedIt 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.
Comment #265
joaopauloc.dev commentedpatch #264(2784233-264-from-262.patch) worked for me in D 10.2.4.
thanks
Comment #266
ershov.andrey commentedUpdated patch for 10.2.6
Comment #270
tikaszvince commentedUpdated patch for 10.3.1
Comment #272
trackleft2Since 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
Here is the failure I am referring to:
Comment #274
trackleft2We 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.
Comment #275
trackleft2Comment #276
needs-review-queue-bot commentedThe 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.
Comment #277
bfuzze9898 commentedPatch #270 is working for me on 10.3.10. Thanks.
Comment #281
netboss commentedI can also confirm that patch #270 is working for me on 10.4.5. Thank you.
Comment #282
bboty commentedPatch #270 works for me as well (previously mistakenly wrote it didn't but it was by my mistake, actually).
Comment #283
tikaszvince commentedReroll MR2784233 patch for 11.2.x / 11.x latest
Comment #284
tikaszvince commentedReroll MR2784233 patch for 11.3.x / 11.x latest
Comment #286
hmdnawaz commentedPatch 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