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.
follow-up to: #254491: Standardize static caching
see last patch examples: http://drupal.org/node/254491#comment-1430180 and also: http://drupal.org/node/224333#static_variable_api
Apply this conversion pattern to includes/database to convert all static variables there. Pay close attention to any place a reset parameter is provided and add a call to drupal_static_reset() where appropriate (e.g. in any calling function that uses the reset parameter)
Comment | File | Size | Author |
---|---|---|---|
#12 | jamesan_422366-12.patch | 3.55 KB | JamesAn |
#11 | jamesan_422366-11.patch | 4.47 KB | JamesAn |
#10 | jamesan_422366-10.patch | 4.59 KB | JamesAn |
#8 | jamesan_422366-8.patch | 4.59 KB | JamesAn |
#5 | jamesan_422366-5.patch | 5.15 KB | JamesAn |
Comments
Comment #1
pwolanin CreditAttribution: 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 #2
JamesAn CreditAttribution: JamesAn commentedAll the static variables I encountered here didn't seem to ever need resetting.
There were a couple adjustments I made:
Comment #4
Berdir@#2
You can't use function calls when defining static variables, that's why these additional if's are needed.
Comment #5
JamesAn CreditAttribution: JamesAn commentedOops. I missed that PHP detail.. ^^" That explains why the patch didn't work. Yey me and my self-taught PHP knowledge. XD
Comment #6
pwolanin CreditAttribution: pwolanin commentedI might also convert function pager_get_querystring() - for example if a test is executing several different paths during one page load.
Comment #7
Dries CreditAttribution: Dries commentedtheme_pager_link() contains some changes that seem irrelevant to this patch, and that are not documented.
Otherwise this looks fine.
Comment #8
JamesAn CreditAttribution: JamesAn commentedThanks for catching those bits. I've converted pager_get_querystring() and fixed the problem with theme_pager_link().
Comment #10
JamesAn CreditAttribution: JamesAn commentedOy vey.. there was a dangling parenthesis.
Comment #11
JamesAn CreditAttribution: JamesAn commentedI broke up
$string = &drupal_static(__FUNCTION__, drupal_query_string_encode($_REQUEST, array_merge(array('q', 'page'), array_keys($_COOKIE))));
so that drupal_query_string_encode() is only run when $string is NULL.Here it is.
Comment #12
JamesAn CreditAttribution: JamesAn commentedOops! I mistakenly included pager.inc into this issue. Changes to that file belong to #422370: Revisit and convert mail.inc, module.inc, pager.inc to use static caching API. This patch reflects this fix and no longer includes pager.inc changes.
The patch of the other issue reflects this realization too.
Comment #13
Dries CreditAttribution: Dries commentedThanks JamesAn. Committed to CVS HEAD.