Detect first workflow state as equivalent to creation state

Created on 14 February 2025, 3 months ago

Problem/Motivation

Currently our custom form validation routine checks whether the entity is new, and if so simply skips any further validation. This means that even if the original author of the node pushes it into a state they shouldn't (past the initial state), we don't catch it, and happily save it. This breaks the logic of the module in Edit cases, and just punts on figuring out the logic.

Steps to reproduce

  1. Install this module and set it up per normal
  2. Create a new node with a workflow
  3. Set the workflow state to some later state (past the initial one)
  4. Save as Draft
  5. Observe no error that "you can't update workflow state if you're saving as draft" per usual
  6. Node is created with incorrect initial state

Proposed resolution

Incorporate some better checking when the entity is new. Workflow can tell us what the "first state" for a workflow/entity/user is, so we can check whether the current state matches that. If not, we should throw the usual error.

Remaining tasks

Roll a patch to test the fix in situ
Extend tests to cover this case

User interface changes

Module should throw the usual error if you try to change workflow state when creating a new node and saving as draft.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇨🇦Canada spiderman Halifax, NS

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

Comments & Activities

Production build 0.71.5 2024