Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It appears that hook_workflow('transition post')
is not getting called. I need to send emails after the transition is completed, but the Execute
method in WorkflowTransition.php
seems to be missing that code. Is there a reason why this was left out?
Comment | File | Size | Author |
---|---|---|---|
#8 | workflow_notify.zip | 7.87 KB | NancyDru |
#6 | 2546152-6.patch | 881 bytes | NancyDru |
Comments
Comment #2
johnvThis hook is removed in workflow_field, since hook_entity_save() does the same thing. It seemed superfluous.
See node_save():
Comment #3
johnvIt should still work for workflow_node.
Comment #4
NancyDruThis is workflow_field. I have at least two cases where I specifically need to know that the transition has been done, and to which state. (See the workflow_notify module in 7.x-1.x). While I might be able to detect this situation in hook_entity_save(), it would be with considerably more effort.
Comment #5
NancyDruLine 433:
// module_invoke_all('workflow', 'transition post', $old_sid, $new_sid, $entity, $force, $entity_type, $field_name, $this);
// We have a problem here with Rules, Trigger, etc. when invoking
// 'transition post': the entity has not been saved, yet. we are still
// IN the transition, not AFTER. Alternatives:
// 1. Save the field here explicitely, using field_attach_save;
// 2. Move the invoke to another place: hook_entity_insert(), hook_entity_update();
// 3. Rely on the entity hooks. This works for Rules, not for Trigger.
// --> We choose option 2:
// - First, $entity->workflow_transitions[] is set for easy re-fetching.
// - Then, post_execute() is invoked via workflowfield_entity_insert(), _update().
Note that those hooks also occur before the actual writing to the database (node_save is a db transaction).
Comment #6
NancyDruThis works for me.
Comment #7
NancyDruComment #8
NancyDruBTW, here is a 7.x-2.x version of workflow_notify.
Comment #10
johnvThe workflow_notify module is now added to the repository.
Comment #11
johnvThis is my documentation in workflow.api.php for removing hook_post:
Comment #12
NancyDrudeleted
Comment #13
johnvAre you OK with this?
(In D8 even more custom hooks are removed, in favour of hook_entity_CRUD() and hook_ENTITY-TYPE_CRUD(). )
Comment #14
NancyDruI kind of like the original hooks because they are straightforward, but I understand why you're taking them away.