Getting a list of altered fields when saving a node I need to trigger some logic to recalculate certain computed fields based on what fields may have been altered when a user updates a node. So I'm looking to create a function that returns a list of of fields the user has updated.

I've come pretty far by using hook_node_update().

Currently the process is like this.

My hook_node_update looks roughly like this:

function hook_node_update($node) {
  $old_node = node_load($node-&gt;nid);

  // Figure out what fields have been altered.
  $altered = _get_altered_fields($node, $old_node);

  // Recalculate the fields *after* node save.
  drupal_register_shutdown_function('_process_fields', $node, $altered);
}


And the _get_altered_fields function:

function _get_altered_fields($node, $old_node) {

  $changed = array();

  if ($old_node-&gt; field_somefield != $node-&gt; field_somefield) {
    $changed[] = 'somefield';
  } elseif ($old_node-&gt; field_someotherfield != $node-&gt; field_someotherfield) {
    $changed[] = 'someotherfield';
  }

  return $changed;
}


The problem with the above is that I get 'false positives' (i.e. 'someotherfield' gets registered as changed even though it is not) because the $node object does not have the exact same data structure as $old_node, which was fetched from the database. In general $node has more attributes - especially if it is a taxonomy field - such as 'vid', 'weight' and 'rdf_mapping'.

I tried creating a normalize function where I unset those attributes, but it gets very messy. I figure someone must have done this before me. Any suggestions how to do this in a clean way?
The simple way of recalculating and update field without any effect of other field is hook_entity_update or code like display here.

&lt;?php
$entity_instance = entity_load('entity_name', array($id));
$entity_instance-&gt;field_myfield[LANGUAGE_NONE][0]['value']= 5;
$entity_instance-&gt;save();
?&gt;