The workflow history for state changes are being saved twice. This is because the history is being saved from both the 'submit' action and the 'update' action. I believe that the call needs to be removed from 'submit' as the 'update/insert' will get called regardless. This will prevent the double entry.

The original 'submit' code is:

function workflow_tab_form_submit($form_id, $form_values) {
  $node = $form_values['node'];
  
  // mockup a node so we don't need to repeat the code for processing this
  $node->workflow = $form_values['workflow'];
  $node->workflow_comment = $form_values['workflow_comment'];
  $node->workflow_scheduled = $form_values['workflow_scheduled'];
  $node->workflow_scheduled_date = $form_values['workflow_scheduled_date'];
  $node->workflow_scheduled_hour = $form_values['workflow_scheduled_hour'];
  
  // call node save to make sure all saving properties run on this node
  node_save($node);
  
  $sid = $form_values['workflow'];

  // make sure new state is a valid choice
  if (array_key_exists($sid, workflow_field_choices($node))) {
    workflow_execute_transition($node, $sid, $form_values['workflow_comment']); // do transition
  }
  return 'node/' . $node->nid;
}

The call to workflow_execute_transition should be removed and deferred to the update.

The change should be:

function workflow_tab_form_submit($form_id, $form_values) {
  $node = $form_values['node'];
  
  // mockup a node so we don't need to repeat the code for processing this
  $node->workflow = $form_values['workflow'];
  $node->workflow_comment = $form_values['workflow_comment'];
  $node->workflow_scheduled = $form_values['workflow_scheduled'];
  $node->workflow_scheduled_date = $form_values['workflow_scheduled_date'];
  $node->workflow_scheduled_hour = $form_values['workflow_scheduled_hour'];
  
  // call node save to make sure all saving properties run on this node
  node_save($node);
  
  $sid = $form_values['workflow'];

  return 'node/' . $node->nid;
}

Comments

mfredrickson’s picture

Status: Active » Fixed

Spot on. Fixed. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)