Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
language system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
3 Apr 2009 at 02:55 UTC
Updated:
3 Jan 2014 at 00:07 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
JamesAn commentedLet's give this static catching change a shot!
Comment #3
JamesAn commentedBah. I misunderstood; I was wondering why the first parameter was always __FUNCTION__ and then realized, that was just to ensure the parameter was unique. So functions with multiple static vars need to rename subsequent strings sent into drupal_static. I gets it now!
Comment #4
JamesAn commentedGah. Forgot to flip the switch.
Comment #5
pwolanin commentedPer discussion w/ catch - if you have a variable name more complex than just __FUNCTION__, use a ':' to separate the suffix (this will avoid colliding with any other valid function name). e.g. :
Comment #6
JamesAn commentedGotcha. Here's attempt #3!
Comment #7
dries commentedThe default value of drupal_static() is NULL so you don't need to pass that in explicitly. See the last chunk of your patch.
Comment #8
pwolanin commentedPer IRC discussion, in this case I might write something like this, since the logic suggests there is some decoupling between header and string processing, but we want to reset strings and report at the same time.
Comment #9
JamesAn commented@Dries: Thanks for pointing that out. It's fixed.
@pwolanin: I don't know. The logic and purpose of
$stringsand$reportseem pretty distinct to me. I don't think it'd be good to group them together like that as it creates an exceptional case wheredrupal_static_reset()will reset two variables, but not the third.There should be a way to either reset specific vars (as it is now) or bulk-reset all vars of a function. Resetting some and not others seems a bit too ad-hoc, in my opinion. yes/no?
Comment #10
dries commentedWhile we are at it, we might want to rename 'headerdone' -- we don't usually glue variable names together.
Comment #11
pwolanin commented@JamesAn - either way is ok for me - this function doesn't have any reset functionality currently, so no real expectation to meet.
Comment #12
JamesAn commentedheaderdone changed to header_done.
@pwolanin, yea, reset doesn't happen there.
Comment #13
pwolanin commentedLooks good
Comment #14
pwolanin commentedSince all tests pass and code style looks fine, I think it's good enough.
Comment #15
dries commentedThis looks like proper use of the static caching API. Committed to CVS HEAD. Thanks.