--- workflow.inc.orig 2011-07-08 18:46:44.664202912 -0400 +++ workflow.inc 2011-07-08 20:13:23.865384523 -0400 @@ -539,8 +539,14 @@ function workflow_transition($node, $sta // Make sure new state is a valid choice. if (array_key_exists($state_name, workflow_field_choices($node))) { if (!$node->workflow_scheduled) { + // Clear $node->workflow_comment so we don't process comment more + // than once in case of subsequent nodeapi updates during one request + // Modules that hook on workflow should get comment from DB (directly or using Token module) + // instead of taking it out of $node object. + $comment = isset($node->workflow_comment) ? $node->workflow_comment : NULL; + unset($node->workflow_comment); // It's an immediate change. Do the transition. - workflow_execute_transition($node, $state_name, isset($node->workflow_comment) ? $node->workflow_comment : NULL); + workflow_execute_transition($node, $state_name, $comment); } else { // Schedule the the time to change the state. @@ -583,7 +589,7 @@ function workflow_transition($node, $sta '!scheduled_date' => format_date($scheduled), ); watchdog('workflow', '@node_title scheduled for state change to %state_name on !scheduled_date', $t_args, WATCHDOG_NOTICE, l('view', "node/$node->nid/workflow")); - drupal_set_message(t('@node_title is scheduled for state change to %state_name on !scheduled_date', $t_args)); + drupal_set_message(t('@node_title is scheduled for state change to %state_name on !scheduled_date (processed every 15 minutes).', $t_args)); } } } @@ -669,14 +675,14 @@ function workflow_execute_transition($no global $user; $old_state = workflow_node_current_state($node); if ($old_state == $state_name) { - // Stop if not going to a different state. - // Write comment into history though. + // Write comment into history. + // No comment and no state change means do nothing. + // We clear comment in workflow_transition() so empty subsequent runs terminate here if ($comment && !$node->_workflow_scheduled_comment) { $node->workflow_stamp = time(); db_query("UPDATE {workflow_node} SET stamp = %d WHERE nid = %d", $node->workflow_stamp, $node->nid); $result = module_invoke_all('workflow', 'transition pre', $old_state, $state_name, $node); _workflow_write_history($node, $state_name, $comment); - unset($node->workflow_comment); $result = module_invoke_all('workflow', 'transition post', $old_state, $state_name, $node); // Rules integration