Needs work
Project:
Drupal core
Version:
main
Component:
taxonomy.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
6 Aug 2017 at 18:30 UTC
Updated:
28 Aug 2023 at 16:53 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
mikeker commentedUpdated to include deleting and rearranging terms.
Comment #3
lendude@mikeker nice find.
This adds the right cachetag when I export the View, but the tag never gets hit when I add a tag...it doesn't even exist in the cachetags table. But this works if I manually invalidate the tag in the database.
Cache tag:
So I think there might be an issue in Taxonomy too that needs to get fixed before this patch has any effect.
Comment #4
lendudeDid some more digging and that tag only get invalidated when you change the actual config of the vocabulary. Apparently adding or changing terms doesn't fall under that.
There doesn't seem to be a vocabulary specific version of the 'taxonomy_term_list' tag, so the only option here would be to add that. Seems like overkill but better then looking at old content I'd guess.
Comment #7
lendudeNow with tests and a check if the vocab exists.
Comment #8
lendudeForgot to tag VDC
Comment #9
lendudeNow with proper Cache::mergeTags use.
Comment #10
dawehnerI think this generic list cache tag is totally fine, especially because terms don't change constantly.
I think we should have a test which fails without the fix but more from a user point of view, aka. ensure that the terms are always up to date. Do you think this makes sense?
Comment #11
mikeker commentedCame across this issue with another project recently and it seemed familiar... :)
For the initial fix, I agree. But I'll add a followup to do this on a vocabulary-by-vocabulary basis. Sites that allow freetagging of content (for example) are going to be constantly blowing away their entire taxonomy_term_list cache which will affect other larger vocabularies on that site.
Not sure I follow you on this, @dawehner... Do you mean a test that verifies the results of steps #6 and #8 in this IS?
Comment #12
mikeker commentedMinor typo fixes in the IS.
Comment #13
mikeker commentedAdded #2920913: The taxonomy_term_list cache should be invalidated on a vocabulary-by-vocabulary basis, and postponed it until this issue is resolved.
Comment #16
jelle_sRerolled patch #9
Comment #17
reszli#16 worked fine for me on 8.7
submitting same file to test against 8.7.x-dev
Comment #18
wim leersI think that #3067937: Views Exposed Filter Block not inheriting the display handlers cache tags, causing filter options not to appear may fix this too.
Comment #19
tvalimaa commentedHi, when I added this patch I got watchdog flood problem "More than one
Taxonomy terms on node" as relationship for "Term" exposed filter results in Trying to get property of non-object in Drupal\views\ManyToOneHelper->addTable()(issue #2882076). Also I try issue 2882076 patch but that didn't fix watchdog flood problem. After I take this (patch 16) patch off that watchdog flood problem when gone so for me I can't use this patchSo I got this issue and https://www.drupal.org/project/drupal/issues/2882076
Comment #20
krzysztof domańskiWe can now add a vocabulary specific
'taxonomy_term_list:BUNDLE'tag. See Added an ENTITY_TYPE_list:BUNDLE cache tag.Limitation: A new
ENTITY_TYPE_list:BUNDLEcache tag has been added to 8.9.x-dev.Comment #22
krzysztof domańskiComment #23
krzysztof domańskiComment #24
mrinalini9 commentedComment #25
mrinalini9 commentedRerolled patch for 9.1.x, please review.
Comment #26
krzysztof domańskiComment #27
bkosborne+1 to this. I removed that comment that is no longer relevant. Patch is against 9.1.x.
Comment #28
bkosborneBTW, Wim said in #18 he suspects #3067937: Views Exposed Filter Block not inheriting the display handlers cache tags, causing filter options not to appear may fix this. It doesn't I tried it. That issue is separate and relates just to exposed filters in a separate block.
My patch didn't change any code, just removed a comment that was irrelevant, so I feel comfortable RTBCing this.
Comment #29
alexpottThis change results in views configuration. This means we need an update path for existing views. For example if you save a view which uses the TaxonomyIndexTid after applying this patch you get the following changes:
Fortunately since this is calculated on save I don't think we don't have to do anything with views provided modules - although it might be nice to somehow tell them we have to export. We have ViewsConfigEntityUpdater for this sort of thing. Not sure. Anyhow we can start by adding a post update to find views that use this filter and re-save them.
Comment #30
bkosborneAh yes, that makes sense. Here's the update hook. Maybe it would be better to only find views that are using the tid filter and save those only? Dunno if that's over optimizing.
Comment #31
hardik_patel_12 commentedLast patch failed to apply re-rolling for 9.1.x , kindly review.
Comment #33
anmolgoyal74 commentedRe-rolled for 9.2.x
Also fixed the CS issues and a typo.
Comment #34
lendudeI think we still need to address @dawehner's point in #10, we should add a functional test for this, to see that this actually leads to the wanted behaviour.
Not sure if the update path needs testing, but I'm guessing it does even though it's pretty trivial
Comment #36
mohit_aghera commented@Lendude
- I've added a simple test case to validate the options in the views exposed form.
Test only patch is failing on local and it is passing with patch.
Comment #38
swentel commentedLooks good to me.
Comment #43
alexpottI think this might be one of the first usages of #2145751: Introduce ENTITY_TYPE_list:BUNDLE cache tag and add it to single bundle listing in core - nice!
One thing I'm wondering is should we only be adding the new cache tags if the filter is exposed. If the filter not exposed I don't think this new cache tag gives us anything apart from more invalidations that are unnecessary - since without the filter being exposed there is no list of taxonomy on the resulting view.
This needs to use the \Drupal\Core\Config\Entity\ConfigEntityUpdater to do this as a batch and this should only be re-saving views that use the filter (or a filter that extends it).
Comment #44
vakulrai commentedupdating tests for point 3 , raised by @alexpott in #43.
Kindly review.
Comment #45
lendude@vakulrai thanks for looking at this
Comment #46
vakulrai commentedThanks @Lendude for pointing out the missed test file, I mistakenly uploaded the wrong patch.
As suggested I have added one more condition to the post_update, to check if the expose filter is using "taxonomy_index_tid" plugin.
Thanks.
Comment #48
vakulrai commentedAdded a condition to prevent unwanted warnings in the loop. Please consider this patch.
Thanks.
Comment #49
vakulrai commentedComment #50
lendude@vakulrai thank you, nice progress, couple of things that I see still:
#43.2 still needs to be addressed, we only want to add this tag if the filter is exposed
#43.3 is partially addressed now, but checking for the plugin ID means we miss all plugins that extend the taxonomy filter, but we also need to update those.
Comment #52
kreatil commentedI came across this issue when searching for a resolution of exposed filters being cached although caching is diabled in their underlying views. In my case, I use exposed filters for building search pages (search_api in combination with solr_api_solr). I place these exposed filters as blocks on certain pages.
Sometimes it happens that after resetting all caches at night, these exposed filters are not rendered. Whatever the reason (perhaps system overload). They are then missing on all pages until the next "hard reset" of caches:
drush cr. I have actually checked several times that the caching of the underlying views is deactivated.I am not quite sure about this, but maybe the cause of the problem described here is deeper?
Comment #54
lammensj commentedI rerolled the patch for Drupal 9.4.
Comment #56
rp7 commentedRerolled #54 so that it applies cleanly to 9.5.x
Comment #57
_utsavsharma commentedFixed CCF for #56.
Comment #58
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #59
ranjith_kumar_k_u commentedRe-rolled #57
Comment #60
ranjith_kumar_k_u commentedComment #61
smustgrave commentedTaking a look at the patch I see the upgrade path but no tests for it.
Comment #62
devkinetic commentedI have a view using database search api that has this issue. Adding/removing terms require a cache flush for them to apply within the exposed filter. This patch doesn't help as it doesn't add cache tags based on taxonomy within the DB search. May be a new issue, but the result is the same.
Comment #63
mohit_aghera commented- Adding a test case for validating config save of views.
- Resolving merge conflicts as patch was not getting applied on 10.1.x head.
Comment #64
smustgrave commentedUpgrade tests look good, and fail locally.
Comment #66
catchCommitted d7bd8ac and pushed to 10.1.x. Thanks!
Comment #68
catch@luenemann pointed out that the patch didn't address #50 and the update may not catch all cases. I think rather than copying more logic to detect when the view needs to be updated we could instead just load and save every view in the update. Reverted so we can re-commit with that change.
Comment #70
lendudeMade the update hook save all Views and added the 'only when exposed' option to the adding of tags and added test coverage for that.
Let's see what this does.
Local update testing seems to be broken for me, so let's see what the bot thinks....
Comment #72
dwwSaw this in Slack, tagging to be smashed. 😉 I hope to look more closely soon...
Comment #74
erichhaemmerle commentedI am on 10.1.2 and I have this same issue. I have some exposed filters that are taxonomies. If I add or edit a content type that has an entity reference to one of these taxonomies, the taxonomy does not show up in my exposed filter as a choice unless I clear the cache. I just applied the patch in #70, but it did not fix the issue. Do I need to apply the patch from #70 AND #63?
Comment #75
devkinetic commentedI haven't been able to work around this issue yet, but I'm still on D9. I ended up installing https://www.drupal.org/project/rebuild_cache_access and instructing my authors of the one and only time to use it, and to schedule that during non peak hours.
I will be on D10 within the next month or so, and can certainly test this again at that point. I'd love to be able to remove that button.