Consider allowing multiple workflow transitions with the same from and to states

Created on 20 January 2017, over 7 years ago
Updated 13 January 2024, 6 months ago

Problem/Motivation

Follow-up from #2779647: Add a workflow component, ui module, and implement it in content moderation β†’ . Workflow::setTransitionFormStates() currently does not allow having multiple workflow transitions which have (an) identical (or at least overlapping) from state(s) and an identical to state:

  public function setTransitionFromStates($transition_id, array $from_state_ids) {
    ...

    foreach ($from_state_ids as $from_state_id) {
      ...

      if ($this->hasTransitionFromStateToState($from_state_id, $this->transitions[$transition_id]['to'])) {
        $transition = $this->getTransitionFromStateToState($from_state_id, $this->transitions[$transition_id]['to']);
        if ($transition_id !== $transition->id()) {
          throw new \InvalidArgumentException("The '{$transition->id()}' transition already allows '$from_state_id' to '{$this->transitions[$transition_id]['to']}' transitions in workflow '{$this->id()}'");
        }
      }
    }

    ...
  }

The benefit of this is that given a from and to state, we can determine the transition ID.

There are valid use-cases for this, though, that are not possible because of this. Quoting @tstoeckler in #2779647-125: Add a workflow component, ui module, and implement it in content moderation β†’ :

I can see why we do this, but I can also see two reasons against it:

  1. Having a transition that is a superset (in terms of the from states) of another transition that is only available to privileged users. This can also be solved by making to transitions where the from states do not overlap, so this is only a half-reason, but it's not completely invalid because the superset could possibly make for a better UI in terms of labelling, etc.
  2. We actually have the concept of "Change classes" in our project, i.e. if you only fix a typo it triggers something different than if you only change content. This could also be solved by adding additional states (possibly with auto-transitions) so is also only a half-reason, but I wanted to bring it up.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component
OtherΒ  β†’

Last updated about 11 hours ago

Created by

πŸ‡©πŸ‡ͺGermany tstoeckler Essen, Germany

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡ΊAustralia sime Canberra

    I am currently using Workflow Buttons β†’ module which takes a transition name and exposes it as a button. This has been working exceptionally well to give the user a much better sense of what they are trying to achieve rather than what the end moderation state will be.

    For example a user sees a button [Save Progress] (the name of the transition) and this might push content from Published to Incomplete.

    With this in place I can also add triggers when certain transitions are used. This means that when [Save Progress] is triggered I can send an email to that says "Hey well done for saving progress, but you'll need to come back later and finish the job".

    So, now I want to add a transition [Request Review] and the permissions are set such that only Managers can execute this. This transition can also move content from Published to Incomplete. This means that I can send an different email when this transition is executed, as it has a different intention that than the transition that normal users can use.

    There are a couple of considerations...

    • Workflow Buttons module is simply looking at the options on the form by default and finding the best transition. Maybe it could do it a different way and load the transitions that are applicable. This then makes the problem one that can be solved in Workflow Buttons.
    • If I was to use the ECA module it works by detecting the FROM->TO state and doesn't offer an ability to detect the transition used.

    In the end, I just don't know why you can't have transitions that cover the same FROM->TO. It doesn't make any sense why this is enforced, and if it wasn't enforce it would allow more creative ways for contrib module to leverage the "transition as a verb" idea that was lost when core replaced buttons with a state drop-down.

  • πŸ‡¦πŸ‡ΊAustralia sime Canberra

    The benefit of this is that given a from and to state, we can determine the transition ID.

    This is a benefit but not critical - we can already order transitions, so determining the appropraite transition is a case of:

    1. What transitions are valid for these from/to states
    2. What transitions does the user have permission to use
    3. Which transition has the highest priority.
Production build 0.69.0 2024