Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
forms system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
3 Apr 2009 at 02:53 UTC
Updated:
3 Jan 2014 at 00:07 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
JamesAn commentedComment #3
JamesAn commentedOops. I missed something. I'll get to it tomorrow.
Comment #4
pwolanin commentedComment #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 commentedTry, try, try again!
Comment #7
pwolanin commentedThis patch seems to add a couple resets that were not present in the existing code, such as:
Can you explain the reasoning behind this?
Comment #8
JamesAn commentedSorry for the lack of explanation. Those resets were supposed to be there in the first place.
form_options_flatten() resets on every call by default, unlike some of the other reset features. That wasn't taken into account in the first patch, but it's reflected here with additional reset calls.
Comment #9
pwolanin commentedIf all current calls to it reset, maybe that logic should be preserved, rather than requiring an extra function call each time - probably need input from eaton, chx, or some other FAPI guru.
Comment #10
pwolanin commentedexplanation from chx:
chx suggests we open a separate issue to clean up function form_options_flatten(), but leave it alone in this patch.
Comment #11
dries commentedI think it is bad form for function A to blow out the static variable from function B. Regular static variables can't do that. Only tests should blow away a static variable from underneath another function. If function A blows out a static variable from function B, we might as well start using goto's. Bring back the $reset parameter please -- it makes for more readable and predictable code.
Comment #12
pwolanin commented@Dries - part of the point was to eliminate the reset parameters that make for odd and unpredictable function signatures. We absolutely want to be able to externally clear the static cache - see the taxonomy module now. For example, we clear cached data about vocabularies whenever a vocabulary is saved or deleted. This is exactly what we want to be able to do.
These static variables are just a temporary cache - the only effect of wiping them is the cost of rebuilding the data.
Comment #13
JamesAn commentedOk. The patch ignores the reset parameter in form_options_flatten() and adds a comment referencing this discussion.
Comment #14
JamesAn commented%*&@#$^!!
I'm sure I flipped the status switch here. Methinks sometimes the status is not switched if I select a change and then upload the file. =\ Or maybe I'm just forgetful.. -.-
Comment #15
JamesAn commentedI've opened an issue for form_options_flatten() at #437018: convert form_options_flatten() in form.inc to use new static caching API. I've proposed a solution there as well.
Comment #16
pwolanin commentedMinor improvement needed - this does not conform to our normal code style:
Code comments before the function should be 1-line doxygen describing the function.
You could include a show comment within the function body summarizing why the conversion was not done, but I would not reference the issue directly. Generally those references in code are only in rare cases where we are working around a bug expected ot be fixed later.
Comment #17
JamesAn commentedSorry for the delay.. here's the fixed patch.
The comment is moved into the function and says:
Comment #19
JamesAn commentedHrm. That patch I uploaded didn't even include all the changes.
Here's the correct patch.
Comment #20
dries commenteddrupal_static_reset('form_set_error')a developer can't discover because it doesn't have API documentation,form_set_error(NULL, '', TRUE)is a bit ugly. Better than callingdrupal_static_reset('form_set_error')orform_set_error(NULL, '', TRUE)is calling something likeform_clear_error()-- this can be documented and would be nice, clean and intuitive.Comment #21
eojthebraveThis comment,
Should probably be something like
Comment #22
eojthebraveOops. Changing status to needs work.
Comment #23
JamesAn commented@Dries, form_clear_error() sounds like a decent compromise to me.
@eojthebrave, thanks for catching that typo! I do that occasionally.. ^^"
Try, try, try again...
Comment #24
JamesAn commentedtestbot?
Comment #25
dries commentedLooks like a nice clean-up to me. Will commit later unless someone objects.
Comment #26
catchLooks fine to me, and form_clear_error() seems like a decent pattern we can use elsewhere (I think we're already doing that elsewhere when there's more than one static which needs to be cleared).
Comment #27
dries commentedI agree that this is an acceptable pattern ... Committed to CVS HEAD.