foreach (field_info_instances('commerce_product', $type) as $name => $instance) {
          // A field qualifies if it is single value, required and uses a widget
          // with a definite set of options. For the sake of simplicity, this is
          // currently restricted to fields defined by the options module.
          $field = field_info_field($instance['field_name']);

$instance['field_name'] is also just the $name.

Though that would probably be better called $field_name.

#3 1784508-3.field_name.patch1.65 KBrszrama
PASSED: [[SimpleTest]]: [MySQL] 3,570 pass(es). View
Members fund testing for the Drupal project. Drupal Association Learn more


thomaske’s picture

I cloned the 7.x.1 structure and searched the files for the offending code.

I found what appears to be the code in a module called

But the reference does not have the comments found in the quoted section. And it appears that if you change the name of the variable, it will overwrite a variable with the same name listed a few lines earlier.

Has it been changed significantly in the .dev version? Please advise.


joachim’s picture

I can see it in the latest dev.

Search for the string 'A field qualifies if it is single value'

rszrama’s picture

Status: Active » Needs review
1.65 KB
PASSED: [[SimpleTest]]: [MySQL] 3,570 pass(es). View

I'm hesitant to change this. It's a bit of "if it ain't broke, don't fix it." As far as I was concerned, "$name" was the instance name - but it was mostly just a throwaway key value (you can see it isn't used anywhere inside that loop). However, looking at _field_collate_fields(), it is in fact keying the array per bundle by the instance field name. We'll make sure it passes test bot, and I suppose there's no reason not to change it.

A file name next time would help. ; )

joachim’s picture

Sorry! I think this was one of those things I meant to make a patch for and then forgot!

rszrama’s picture

Status: Needs review » Fixed

Cleaning up my backlog; just committed this.

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