Problem with node_save within a loop Within an instance of hook_submit (for a custom form), I'm trying to iterate over a list of nodes, updating each of them. The general outline is 

$x = node_load_multiple($nids);
$data = array(--some data--);

foreach ($data as $row) {
  $node = $x[$row['nid']];
  $node-&gt;field_some_field['und'][0]['value'] = $row['some_field'];
  node_save($node);
}

drupal_set_message('Nodes updated');


The problem I'm having is that rather than looping through the whole data array and then posting my confirmation message on the form page, Drupal updates the first node, exits the loop, and redirects to the user's home page with the message 'contenttype TITLE updated.' 

Possibly relevant: I could have sworn this code block worked when the site was 7.2, but after updating to 7.23 I'm seeing this.
To summarize one of the comments, when you encounter weirdness with the API, you need to do two things.

First, look at the API call you are using, and see what hooks it invokes.  Then, check your code for any hook implementations that could cause the weirdness.  In this case node_save() invokes a few: hook_node_presave(), hook_entity_presave, hook_node_update, and hook_node_update for nodes that exist.

Second, you need to check any Rules that are attached to the the API call you are doing.  In this case, you would check for rules that run when nodes are saved.

Doing these two things will usually lead you to the problem.