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.
I just tried to re-order my term-data and set new parents for the terms. Unfortunately the structure is not updated in frontend. After clearing cache everything is working fine again..
Comment | File | Size | Author |
---|---|---|---|
#8 | 1901844-1.patch | 640 bytes | charlie-s |
Comments
Comment #1
stBorchertCommitted to 7.x-1.x-dev so it should be available in the next development release (>"7.x-1.3+4-dev").
Comment #2
stBorchertCommitted and created a new release: 7.x-1.4.
Comment #3
stBorchertComment #4
charlie-s CreditAttribution: charlie-s commentedI'm using 7.x-1.6 and am experiencing this. Is it possible the problem was re-introduced?
Comment #5
thedotwriter CreditAttribution: thedotwriter commentedSame here with 7.x-1.6, clearing the cache is needed to get the correct structure.
Comment #6
mariusm CreditAttribution: mariusm commentedPlease update 7.x-1.6
Comment #7
charlie-s CreditAttribution: charlie-s commentedI will check into this more and update with a patch if needed. Clients definitely needing terms to instantly appear in these forms in the correct position.
Comment #8
charlie-s CreditAttribution: charlie-s commentedI've found the issue.
Ultimately, it lies in
taxonomy_get_tree()
caching taxonomy trees – https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/f....When you submit the taxonomy sort form (admin/structure/taxonomy/vocabulary_foo), SHS tried to update it's cache of the vocabulary options. It looks like it's replacing the cache with the result of
taxonomy_get_tree()
, which, even tho the form's submit handler updated all of the term weights / hierarchy, the terms have already been loaded into memory during this bootstrap cycle and thus their new weight isn't taken into consideration.Patch unsets this cache via
drupal_static_reset('taxonomy_get_tree');
. Tested and working for me.Comment #9
f0ns CreditAttribution: f0ns commentedPatch #8 seemed to work at first sight, still had issues. Fixed it by adding this code in a custom module named "shs fix"
If anyone has a better way to solve this, please feel free to share.
Comment #10
charlie-s CreditAttribution: charlie-s commentedI was also still running into the issue where re-ordering a 2nd level item never appeared in SHS until a full cache clear. Turns out the cache key that was being set only cared about the first level of items. See this code from ~ line 583:
Because we only have a generic cache key of "shs:[vid]" then trees below level 1 are never cached. I appended the parent ID to the cache like so:
$cache_key = "shs:{$vid}:{$parent}";
and it's working as expected for me now. Can we discuss getting this stuff committed?
Comment #11
4fs CreditAttribution: 4fs commentedHi csdco,
Can you assist a little further. Not 100% sure what to do with the code above. Can you explain further or provide a patch? Am I correct in that $cache_key = "shs:{$vocabulary_cache_key}"; will be replaced by $cache_key = "shs:{$vid}:{$parent}"; (line 774). Is that correct? Thank you.
Comment #12
Tino CreditAttribution: Tino commentedStill running into this problem. Created a module from #9, but after editing a list and moving a child term back to root, the term does not appear when editing a node with this term. Running 7.x-1.6+56-dev.
Comment #14
stBorchertFixed with commit to #2344653: SHS cache system doesn't work correctly.