Order of workflow status changes

Created on 9 April 2025, 4 days ago

I still have something freaky: sometimes the order of workflow statuses is changed comparing 1.x-dev to v1.8

I do a grep on the weights in the config files:

# grep weight workflow.state.payment*
workflow.state.payment_canceled.yml:weight: 2
workflow.state.payment_closed.yml:weight: 1
workflow.state.payment_creation.yml:weight: -11
workflow.state.payment_errors.yml:weight: -4
workflow.state.payment_errors_returns.yml:weight: -3
workflow.state.payment_errors_returns_refused.yml:weight: -2
workflow.state.payment_instruction_processed.yml:weight: -7
workflow.state.payment_instruction_sent.yml:weight: -8
workflow.state.payment_not_executable.yml:weight: 0
workflow.state.payment_opened.yml:weight: -9
workflow.state.payment_payout_partially_processed.yml:weight: -6
workflow.state.payment_payout_processed.yml:weight: -5
workflow.state.payment_reprocess.yml:weight: -1

With workflow v1.8, the order on screen in the status option list is ("created" is the initial status which isn't shown):
workflow.state.payment_opened
workflow.state.payment_instruction_sent
workflow.state.payment_instruction_processed
workflow.state.payment_payout_partially_processed
workflow.state.payment_payout_processed
...

With workflow 1.x-dev, the order on screen in the status option list is
workflow.state.payment_instruction_sent
workflow.state.payment_opened
workflow.state.payment_instruction_processed
workflow.state.payment_payout_partially_processed
workflow.state.payment_payout_processed
..

I discovered this as one of my behat tests uses the default status while creating a node, which now selected "instruction sent" instead of "opened". Strange thing is, when I change the weight of workflow.state.payment_opened.yml to -10, the workflows appears again in the "right" order:

workflow.state.payment_opened
workflow.state.payment_instruction_sent
workflow.state.payment_instruction_processed
workflow.state.payment_payout_partially_processed.yml
workflow.state.payment_payout_processed.yml
...

At first sight the sorting code in WorkflowState looks ok to me. Weight -9 or -10 shouldn't really make a difference because they're both between -11 and -8. Any idea?

It's very repeatable:
- Change weight in the config file
- drush cim
- drush cr
- And you either get one or the other order

For the rest all the behats for my two biggest projects are now green/ok with version 1.x-dev. Not that guarantees anything 100%, but it's a good sign.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

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

Comments & Activities

  • Issue created by @sboden
  • 🇳🇱Netherlands johnv

    I experienced the same thing on testing.
    I found out that the weights on the workflow setting, stages list were identical.
    Only if i dragged a state, the system renumbered the staties.
    I assume the weights in your yml file are copied to the workflow states setting page.
    But please check.

  • On the "admin/config/workflow/workflow/payment/states" I see the weights from the config files, and on there the statuses are always in the correct weight order.

    When I have weight -9 on payment open, in v1.8 I see "open" as first option in the status list on the node creation page.

    Right after I do a "composer require drupal/workflow:1.x-dev", without drush cim or drush cr, when I refresh the node creation page the payment open status moves to the second place in the list. On the config screen are still in the right weight order. So it has to be something in the workflow code that does something freaky while sorting.

    • johnv committed 812471ff on 8.x-1.x
      Issue #3518172 by sboden: Order of workflow status changes
      
  • 🇳🇱Netherlands johnv

    Please try new dev version. the change might help.

Production build 0.71.5 2024