Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
1. There are problems with deletion of taxonomy terms (term that has been deleted, stored in cache (see attachment img)).
2. Changing taxonomy term weight or parent doesn't work (drupal_static should be reset).
2. Rebuilding the cache does not work correctly (if it concerns of taxonomy terms with parents).
This creates a lot of problems and should be fixed.
Patch attached.
Comment | File | Size | Author |
---|---|---|---|
#13 | shs-cache_system_not_work_correctly-2344653-13.patch | 2.74 KB | alan-ps |
993x684-file_24_09_2014_004.png | 21.82 KB | alan-ps |
Comments
Comment #1
alan-ps CreditAttribution: alan-ps commenteddrupal_static_reset should be only for taxonomy_get_tree.
Replaced drupal_static_reset() to drupal_static_reset('taxonomy_get_tree').
Comment #2
nevergone CreditAttribution: nevergone commented#1 tested and works well!
Comment #3
joelpittetGot bit by this one, so bumping.
Comment #4
joelpittetand a big +1 from me for the RTBC. This fixed a nasty error page!
Comment #5
CatherineOmega CreditAttribution: CatherineOmega commentedLooks good! Can we roll a new version?
Comment #6
pcambraI don't think this is needed, if there's some other submit handler it will be stripped, won't it?
Comment #7
joelpittet@pcambra that is just moving it from the front to the end. It won't strip anything out.
Comment #8
l0keSince upgrading to dev was not a good option for me, I've made port to 7.x-1.6.
Just want to share if someone will need it.
Comment #9
joelpittetSmall bump, #1 is still RTBC. I'm hiding #8 as it may confuse the maintainer.
Comment #10
stBorchertThis does not work if you reset the vocabulary to alphabetic order.
$form['#vocabulary']
does not exists in that case.Can you explain, why you move the submit handler to the end?
Why do you remove the logic of updating the terms parents here?
Try moving a term to a different point within the hierarchy and select one of its former parents within the widget ...
Comment #11
joelpittet@stBorchert it may be tricky to get responses to this, the original patch was in Sept 2014.
re #4 I came in because there was a traceable fatal error that was mitigated by this patch. If I recall correctly, it was with article tags, and it would fatal when adding or removing more than one tag on the field.
If I had to guess on #10.2 it would be moved to the end to let the normal taxonomy form submit handlers run first and possibly prime the cache.
I'll see if I can reproduce the problems you indicate with #10.1 and #10.3, as I haven't run into those yet. But it was very easy to hit that fatal as my client did it by adding a couple article tags.
Comment #12
joelpittetWish I could tell my past self to write down notes on the issue... I can't reproduce the problem. It could have manifested with cache_consistent + redis which I was using back then.
Comment #13
alan-ps CreditAttribution: alan-ps commentedI'will try to remember what this patch do and explain in short:)
So, the original problems:
(1) Term that has been deleted is stored in a cache. Steps to reproduce:
- Create term "Tag A" and add it to a node;
- Remove term "Tag A".
- Edit node. Term is still present in a field.
In order to fix it we should reset static variable (taxonomy_get_tree) before shs_term_get_children() will be executed:
It won't work, because shs_form_taxonomy_form_term_submit() is executed before the original submit taxonomy_form_term_submit(), so:
#10.2
and this (#10.3) in order to rebuild the shs cache:
This won't break nothing. This is executed, after the confirmation of deleting taxonomy term.
This is related to shs_form_taxonomy_overview_terms_submit() and this is the second problem.
(2) Rebuilding the cache does not work correctly (if it concerns of taxonomy terms with parents).
The patch is fixed this problem (it doesn't work with original code).
About #10.1:
I didn't remember why I made this change. It seems you are right and it can cause a notice, if we will use "Reset to alphabetic". But from other side $form_state['complete form']['#vocabulary']->vid won't work for "Reset to alphabetic" too. This will avoid notices only.
So, I've prepared new patch, which corrects #10.1, it should work like a charm. I guess, I missed nothing:)
Comment #14
alan-ps CreditAttribution: alan-ps commentedComment #15
stBorchertIf you edit a term and select a new parent for the term the cache for all parents within the hierarchy needs to be rebuild. I guess this was the reason why the submit hook needs to run first. Unfortunately I can't remember :)
Whoa, every time I see this "node-count" thing it makes me want to simply remove it completely (as done in 8.x). This is so ugly in terms of caching :(
Comment #16
alan-ps CreditAttribution: alan-ps commentedhmm, probably I don't understand something but it is executed after deletion of a taxonomy term (I mean this function shs_form_taxonomy_form_term_submit()). We can't do this "moving a term to a different point" here. This is a part of code where submit is added:
It works fine. I checked different ways. Try to apply patch;)
I don't think that there is some problems with cache:)
Comment #18
stBorchertCommitted some other changes that should fix this too.