Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
taxonomy.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
7 May 2007 at 18:53 UTC
Updated:
2 Jan 2014 at 23:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
drummThe static variables should be named for what they store, instead of $cache.
This should go into 6.x andthen be backported if necessary.
Comment #2
moonray commentedUpdated the patch with changed static variable names. Also added measures to prevent corruption of the cached objects.
Comment #3
zoo33 commentedI tested a cached version of taxonomy_get_parents on Drupal 5 and Ubercart's catalog block benefits a lot from it. I'm sure similar taxonomy based menu structures will to. I agree that an optimization such as this one would be worth backporting to 5.x.
However, I not sure why the static variable needs protection?
Comment #4
dries commentedThe problem with this patch is that it also can break the API; when you do 'get - alter - save - get' you'll get an old copy of the data, not the updated version. This might be a little tricky ...
Comment #5
zoo33 commentedMaybe a $cachable argument would do it?
Comment #6
RobRoy commentedPlease see my taxonomy_get_tree() cache patch at http://drupal.org/node/106015. Maybe that would help. At least they both should use the same implementation. I removed the static var there but may need to bring it back so we only pull from the cache once per page request.
Comment #7
catchStill applies but marking as needs work per Dries.
Comment #8
catchBumping to 7.
Comment #9
catchtagging.
Comment #10
catchThis is still valid, fresh patch.
Comment #11
brianV commentedLooks good from an 'the code works' perspective, however, the anal part of me noted that the logic is reversed between instances. For taxonomy_get_children(), I would put the return of the cached $children variable in the 'if', and generate the value in the 'else' to be consistent with the other function.
10 days to code freeze. Better review yourself.
Comment #12
catchYeah I thought about that when writing it, but couldn't decide which was best, sometimes it's better to just pick one though :p here it is as requested.
Comment #13
brianV commentedYay - looks great!
Comment #14
webchickHm. It's not clear to me in my current, bleary-eyed state whether the most recent patch addresses Dries's concern at #4. Could someone enlighten me?
Comment #15
catchThat's covered by drupal_static() and taxonomy_static_reset().
Comment #16
dries commentedComitted to CVS HEAD. Thanks.