Field.info.inc uses 2 functions that have a additional reset parameter this issues builds on teh pattern introduced in #577950: API-cleanup: Factor module_implements $refresh parameter into it's own function to tidy up some additional functions.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

marcingy’s picture

Status: Active » Needs review
marcingy’s picture

Title: Clean up reset patterns in field,info.inc » Clean up reset patterns in field.info.inc
sun’s picture

Status: Needs review » Needs work
+++ b/modules/field/field.info.inc
@@ -29,20 +29,14 @@ function field_info_cache_clear() {
- *   If $reset is FALSE, an array containing the following elements:

@@ -157,15 +150,18 @@ function _field_info_collate_types($reset = FALSE) {
- *   If $reset is FALSE, an array containing the following elements:

Let's keep "An associative array containing:"

+++ b/modules/field/field.info.inc
@@ -65,21 +59,20 @@ function field_info_cache_clear() {
+function _field_info_collate_types() {
...
-  static $info;
...
+  static $drupal_static_fast;

@@ -176,14 +172,14 @@ function _field_info_collate_types($reset = FALSE) {
-  static $info;
+function _field_info_collate_fields() {
...
+  static $drupal_static_fast;

How often is this really called? I'm not sure whether the fast pattern is justified here.

-1 days to next Drupal core point release.

marcingy’s picture

Status: Needs work » Needs review
FileSize
5.41 KB

Reroll adding in the array comment and removing fast static.

Lars Toomre’s picture

I like this $reset clean-up patch. I have not tested it, but reviewing the latest patch, it looks good to go.

sun’s picture

Hm. The correlation between the collator and the reset function isn't obvious unless you already know that both exist. We should prevent people from simply using drupal_static_reset().

Let's add @see respective lines to the end of the phpDocs of both functions.

marcingy’s picture

Have added @see but I'm not 100% sure they are necessary as these are internal functions given the _field namespacing and external calls should be utilising field_info_cache_clear() rather than calling these functions.

yched’s picture

Status: Needs review » Needs work

the @see mentions need () after the function names.
Other than that, fine by me.

marcingy’s picture

Status: Needs work » Needs review
FileSize
5.66 KB

Adding () to @see

yched’s picture

Status: Needs review » Reviewed & tested by the community

This will probably get refactored with #1040790: _field_info_collate_fields() memory usage (when I can get back to it...), but meanwhile, sounds good.

yched’s picture

Status: Reviewed & tested by the community » Needs work

Hm, wait a sec.
_field_info_collate_types() and (mostly) _field_info_collate_fields() can be called quite a bit during a request.

Moving the statics in there over to drupal_static() should have happened long ago (I think there were two concurrent patches somewhere in the queue, that just neutralized each other...), but I'd rather have them use the $drupal_static_fast pattern (as was done in the original patch above).

marcingy’s picture

Status: Needs work » Needs review
FileSize
6.17 KB

Back to drupal fast static pattern.

yched’s picture

FileSize
6.17 KB

Straight re-upload for the bot

yched’s picture

Status: Needs review » Reviewed & tested by the community

Thanks !

catch’s picture

Status: Reviewed & tested by the community » Fixed

Looks like good cleanup, committed and pushed!

Status: Fixed » Closed (fixed)

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