Transition pre hook is broken

Created on 12 September 2024, 2 months ago
Updated 18 September 2024, about 2 months ago

Problem/Motivation

I have implemented hook_workflow, and use the 'transition pre' operation to validate certain conditions. In some cases my code return false to prevent the transition from working.

After upgrading to 8.x-1.8, I found that upon returning false from my hook, the workflows module
* logged that the transition was vetoed (good)
* did not create a workflow transition record in the database (good)
* updated the workflow status to the new state (bad!)
* saved the record (good)

🐛 Bug report
Status

Active

Version

1.8

Component

Miscellaneous

Created by

🇨🇦Canada jdhildeb

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @jdhildeb
  • 🇬🇧United Kingdom hughworm

    I have the same problem. In addition to using the "transition pre" case to validate and veto transitions, I've used it to set various fields on the entity when the workflow state changes, as indicated by the comments in workflow.api.php:

        case 'transition pre':
          // The workflow module does nothing during this operation.
          // Implement this hook if you need to change/do something BEFORE anything
          // is saved to the database.
          // If you return FALSE here, you will veto the transition.
    

    This no longer works. I have reverted to 8.x-1.7 to allow the site to continue to function.

    I found that in workflow.module the call to execute transitions had changed from within the workflow_entity_presave hook to the workflow_entity_update hook (117b4cec544cc4a5d74fe97cc04fa5ce07479a6a), which explains the changed behaviour.

    But I also noticed that CRUD hooks are removed altogether in latest dev code. 

    So I'd be very grateful if someone could tell me where I should move the logic currently implemented in hook_workflow to, for compatibility with future releases?

  • 🇷🇸Serbia milos.vucijak

    Same problem here

Production build 0.71.5 2024