Closed (fixed)
Project:
Workflow
Version:
5.x-1.0-beta1
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
5 Feb 2007 at 21:20 UTC
Updated:
16 Mar 2007 at 20:00 UTC
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
Comment #1
mfredrickson commentedSpot on. Fixed. Thanks.
Comment #2
(not verified) commented