What to do when saving nodes one-by-one and bulk resaving give different results I'm using the Location Taxonomize module with the Address Field module to create a vocabulary of node locations.

I want to re-create the locations from scratch, and I have a term reference field attached to the node.  This term reference field contains a reference to the automatically generated Location Taxonomize vocabulary.

The problem is, after I delete the vocabulary and term reference field and then re-create them, I cannot use VBO to re-save my nodes to automatically generate the Location Taxonomize terms and fill in the term reference fields.  Instead, I have to save the nodes one-by-one, but there are 30,000+ nodes.

In other words: saving nodes individually works fine, but saving nodes in bulk does nothing.

The relevant code from Location Taxonomize Address Field submodule looks like this:

function location_taxonomize_af_element_submitted($form, &amp;$form_state) {
  $lang = 'und';
  // Act on values
  $fields = $form_state['temporary']['addressfields'];
  $items = array();
  foreach ($fields as $field) {
    $deltas = $form_state['values'][$field][$lang];
    foreach ($deltas as $delta =&gt; $values) {
      // Don't process 'add more'.
      if (is_numeric($delta)) {
        // Add the Administrative Area name, if possible
        if (isset($form[$field][$lang][$delta]['locality_block']['administrative_area']['#options'])) {
          $options = $form[$field][$lang][$delta]['locality_block']['administrative_area']['#options'];
          $values['administrative_area_name'] = $options[$values['administrative_area']];
        }
        // Add the country name
        $values['country_name'] = location_taxonomize_get_country_name($values['country']);
        $items[] = $values;
      }
    }
  }
  // taxonomize
  if (!empty($items)) {
    location_taxonomize_taxonomize($items, $form, $form_state);
  }
}


As far as I can tell, this code is added by a submit handler, so when the nodes are re-saved using VBO, the submit handler is not called (I could be wrong about this; I am in over my head in this part of Drupal).  What I want to do is force this bit of code to be called with VBO-- I know how to make a Rules action in code, but for nodes, that gives me the variable $node, not $form.  Is there some way to go from $node to $form to run this code?  Or, is there some way to re-save a node in a bulk operation as if it were saved individually?
You are correct that function is attached to the actual edit form when using the field, and therefore is bypassed during a VBO node save. This allows the function to be attached to any entity type that has the field (there are other ways to do this, but this approach was almost certainly easier than other options).

You can get from a node to a form using drupal_get_form() and providing the node as the form_state:

$form = drupal_get_form('YOUR_NODE_TYPE . '_node_form', $node);


Note: I have not tested that solution in your use-case.