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 all modules 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)

Note this can be considered a place-holder issue - comment if you are working on a specific module.

CommentFileSizeAuthor
#3 static_cache_user.patch6.58 KBmichaelfavia

Comments

pwolanin’s picture

Per 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. :

&drupal_static(__FUNCTION__ . ':second_var');
michaelfavia’s picture

Assigned: Unassigned » michaelfavia

Im starting on node module now and will post patch as i move through them.

michaelfavia’s picture

StatusFileSize
new6.58 KB

First stab at this process please review thoroughly to make sure the rest of these come in cleanly next week. -mf
#423806: Update user module to use drupal_static()
#423822: Update node module to use drupal_static()

JamesAn’s picture

JamesAn’s picture

Status: Active » Needs review

Most of these sub-issues are pretty quick fixes (except for field, locale, node, simpletest, and user).

JamesAn’s picture

There are still two static vars:

modules/simpletest/drupal_web_test_case.php:875:    static $available;
modules/system/system.queue.inc:63:    static $queues;

Both vars in defined within class definitions. I'm assuming you can't register those since there may be multiple instances of the respective classes. Still, it seems like the code is designed so that there won't ever be multiple instances of these two classes. Should these static vars be left alone? Please advice.

Status: Needs review » Needs work

The last submitted patch failed testing.

pwolanin’s picture

Priority: Normal » Critical

setting this one issue as critical to track that all sub-issues are resolved for D7 and that the conversion gets completed

JamesAn’s picture

Status: Needs work » Needs review

Rerolled some of the sub-issues.

Locale, search, and filter still need work.

cburschka’s picture

The remaining issues are now locale, search and trigger. IMHO, locale and search are RTBC, while trigger needs only a tiny code-style fix. Once these three are in, this meta-issue can be closed...

agentrickard’s picture

agentrickard’s picture

A search also reveals 39 uses in 19 files of 'static $var' in /modules and 72 in 29 files inside /includes as of today.

Are we trying to clean all of these up?

cburschka’s picture

@agentrickard, some uses of local statics are legitimate and will not be converted. I forgot the exact criteria, but apparently drupal_static should only be used for variables that might conceivably be reset at some point.

agentrickard’s picture

Right, I read the docs on API. Have we sanity checked all the remaining statics?

catch’s picture

Title: convert all core module to use new static caching API » Convert all core module to use new static caching API
Priority: Critical » Normal
Status: Needs review » Fixed

I'm marking this fixed, if we have un-resettable statics, we can find them individually.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.