Working in 7.x-1.1 I discovered that I am having difficulty reverting a workflow features. I've looked into it further and tracked it down to the way the workflow_update_workflows_full_object function works. After creating the states, we then delete any not in use. However, after adding the transitions there is no call to delete unused transitions. This leaves other transitions still in tact.
I see a few possible ways to fix this:
1) Export every transitions as a feature, even if there are no roles set with it
2) Search through for rogue transitions after importing
3) Delete all transitions for workflow, then build them back up.
I'll post some code for one of these solutions once I get it working.
Comments
Comment #1
nancydruThanks, David.
Comment #2
dforegger commentedHere is a fix. Unfortunately, I don't have a git environment set up and can't create a patch.
In workflow.module around line 1145, add the function:
/**
* Given a wid get the transitions.
*/
function workflow_get_workflow_transitions_by_wid($wid) {
static $transitions;
if(!isset($transitions[$wid])){
$transitions[$wid] = db_query('SELECT t.*, s1.wid FROM {workflow_transitions} AS t INNER JOIN {workflow_states} AS s1 ON t.sid=s1.sid INNER JOIN {workflow_states} AS s2 ON t.target_sid=s2.sid WHERE s1.wid = :wid AND s2.wid = :wid',
array(':wid' => $wid))->fetchAll();
}
return $transitions[$wid];
}
In workflow features, at line 146:
workflow_update_workflow_transitions($transition);
+ $active_transitions[] = $transition->tid;
}
+ //Delete any transitions in our workflow that are *not* in our original construction
+ foreach (workflow_get_workflow_transitions_by_wid($workflow->wid) as $transition) {
+ if(!in_array($transition->tid, $active_transitions)) {
+ workflow_delete_workflow_transitions_by_tid($transition->tid);
+ }
+ }
Comment #3
nancydruMarking for my review
Comment #4
nancydruCommitted with attribution.