Posted by meba on April 5, 2009 at 12:00pm
Jump to:
| Project: | Workflow |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (won't fix) |
| Issue tags: | workflow |
Issue Summary
Hi,
in workflow_execute_transition():
// Notify modules that transition has occurred. Actions should take place
// in response to this callback, not the previous one.
module_invoke_all('workflow', 'transition post', $old_sid, $sid, $node);
// Clear any references in the scheduled listing.
db_query('DELETE FROM {workflow_scheduled_transition} WHERE nid = %d', $node->nid);This means that the hook is run before the transitions are deleted from the table. Result - i can't respond to a state transition in the hook by scheduling another transition, because the code will delete it immediatelly.
It should be fairly simple to just switch both lines...
| Attachment | Size |
|---|---|
| workflow_transition.patch | 1.25 KB |
Comments
#1
Adding a tag
#2
Is anybody interested in this issue?
#3
I am not directly affected by this issue, just found it via google, but it immediately makes sense to me.
#4
Can you elaborate on this for me? Give me a good example of what you might be trying to do. To me, it makes sense for the hook to run before the action is taken, so that the implementer may query any data beforehand.
Also, moving this to 2.x.
#5
As the topic starter said,
<?phpfunction mymodule_workflow($op, $old_sid, $sid, $node) {
// don't know the exact name of the function that would schedule a transition
_mymodule_schedule_transition($node->nid, ..);
}
?>
Now the newly scheduled transition will be deleted before it can be executed.
Alternative:
- Query SELECT existing transitions for the respective node nid, and store them in a $deleted_transitions array. Maybe with a few JOIN LEFT to fetch state names etc.
- Delete existing transitions for the node nid.
- module_invoke_all('workflow', 'transition post', $old_sid, $sid, $node, $deleted_transitions), with the deleted transitions as an argument.
#6
As previous responder stated - the issue is that you cannot schedule a transition INSIDE a workflow function, because the delete will remove it.
I would personally say it's a bug, therefore belongs to 1.x? (We run workflow 1.x and therefore need to have a patched version). The alternative approach makes sense and I will make a patch if you say you will be able to commit it to 1.x (that's what everybody uses anyway)
#7
I guess it has to go to 2.0 first and then will be backported, as with most projects. Just don't forget the backport..
#8
Oh, ok I understand the problem. Thank you for re-iterating it for me, for some reason on the first read through it didn't quite register. :) I'll move this back to 1.x.
#9
What solution do you prefer? The easy patch I made or something alternative that records deletes first, performs the hook and then does the deletion?
#10
Since this request is over a year old, I'm going to assume a solution was found or you've moved on. If not, please get updated to the latest versions of all modules and make a request for it against Drupal 7 and I'll be glad to take a look at it.