When saving a node, the workflow ng transition rule is triggered, even though workflow has not changed

foxtrotcharlie - May 13, 2008 - 09:04
Project:Workflow
Version:5.x-2.3
Component:-workflow_workflow_ng
Category:bug report
Priority:critical
Assigned:Unassigned
Status:needs work
Description

I'm not sure if this is a bug with workflow, or workflow ng. I have workflow states on a node and using workflow ng have configured a rule that does something on workflow state transition. This works well when i change the state. But once the state has been changed and I edit the node and save it (without changing the workflow state), the workflow ng rule is triggered, even though there has been no workflow state transition. i.e the workflow radio button is left where it was...

Can anyone advise on where I start looking to figure out what's going on?

#1

fago - May 13, 2008 - 13:13
Status:active» fixed

It sounds like a bug in either workflow's workflow-ng integration or in your rules.. ;)

I don't know, how the event is called? Is it supposed to be generated when state doesn't change? If not, file a bug for workflow's workflow-ng integration.

#2

Anonymous (not verified) - May 27, 2008 - 13:22
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

#3

bwo - August 11, 2008 - 16:04
Project:Workflow-ng» Workflow
Version:5.x-2.0» 5.x-2.3
Component:Miscellaneous» -workflow_workflow_ng
Category:support request» bug report
Status:closed» active

I confirm this bug and reopen it here, according to fago's suggest. The event "Workflow has been updated" is registered always when the form on the workflow tab is submited or when a node is updated (if the workflow form is enabled for node edit), even if workflow state actually hasn't been changed.

#4

indianroo - December 16, 2008 - 18:55

The problem is here in workflow.module, line 600 or so:

function workflow_execute_transition(&$node, $sid, $comment = NULL, $force = FALSE) {
$old_sid = workflow_node_current_state($node);
if ($old_sid == $sid) {
// Stop if not going to a different state.
// Write comment into history though.
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_sid, $sid, $node);
_workflow_write_history($node, $sid, $comment);
}
$result = module_invoke_all('workflow', 'transition post', $old_sid, $sid, $node);
return;
}
......

Here it checks that no actual transition is taking place. You could remove the module_invoke_all calls for the pre and post transitions. I would assume that subscribers are not expecting to be called where there is no actual transition. But not sure what else what would break..

#5

berlinonline2 - December 30, 2008 - 12:06
Priority:normal» critical

Having the same problem as foxtrotcharlie with the actual versions of workflow and workflow-ng. Every time saving a node the workflow-ng rule is triggered, also when nothing has changend in the workflow or node. For me it is very important to find a solution. Because this feature is essential to build a workflow with transitions I changed the priority to critical and hope this is ok. Is there anybody who can help out? Thanks.

#6

crea - May 26, 2009 - 03:49

Confirming this bug and subscribing

#7

crea - May 26, 2009 - 03:48
Status:active» needs review

Please try this patch

AttachmentSize
transition_check.patch 880 bytes

#8

crea - May 26, 2009 - 07:22

Same patch should be made for Rules integration in 6.x
I see people experiencing problems with state change event.
No more token comparing in the rule configuration to find out if state actually changed

#9

crea - May 27, 2009 - 16:40
Status:needs review» needs work

This patch has one minor issue: because it disables workflow-ng event completely if state is not changed, workflow-ng event won't fire in case workflow state is not changed but new comment is added. So if you have workflow-ng rules that notifies users about new workflow comments, you probably need better patch than this.
Better patch should split single "Workflow state has changed" event into two: "Workflow state has changed" and "Workflow comment was added". Then one should use latter in workflow-ng notification rule.
Setting to "needs work" because of this.

#10

emilyf - September 24, 2009 - 12:46

patch doesn't find file to patch properly from within workflow module directory. applying patch manually works fine other than issue mentioned above.

 
 

Drupal is a registered trademark of Dries Buytaert.