Problem/Motivation
When editing a Workflow which has been created with either no states or no transitions (or both)) an Invalid argument error will be displayed.
No states: Warning: Invalid argument supplied for foreach() in Drupal\workflows\Form\WorkflowEditForm->copyFormValuesToEntity() (line 276 of core/modules/workflows/src/Form/WorkflowEditForm.php).
No transitions: Warning: Invalid argument supplied for foreach() in Drupal\workflows\Form\WorkflowEditForm->copyFormValuesToEntity() (line 279 of core/modules/workflows/src/Form/WorkflowEditForm.php).
This will only occur in rare cases where the Workflow Plugin does no provide any required states and when creating the Workflow the user chooses not to create the initial state when prompted. In this scenario it appears that in some cases $form_state->getValues() may not contain the states or transitions keys, which results in the errors being shown.
Tested using the Workflows Field contrib module, which provides a plugin with no required states.
Currently this does not appear to be reliably reproducible, no other information is currently available which would indicate why this is not reliably reproducible.
Proposed resolution
Remaining tasks
Determine if code should be refactored to prevent the errors from being triggered, or wait until this can be more reliably reproduced.
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | 2899872-test_only_should_fail.patch | 916 bytes | spokje |
Issue fork drupal-2899872
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
sam152 commentedComment #3
sam152 commentedComment #4
sam152 commentedComment #5
scott_euser commentedI couldn't see how to reproduce this in order to add a test for it. Steps I followed:
Doesn't that mean transitions are essentially required in practice?
Comment #6
sam152 commentedPerhaps you're right, the key would have to be missing from configuration to trigger this, instead of set to an empty array like your testing in #5 suggests.
I think this is fine to close.
Comment #7
aaronmchaleUpdating this issue with more details as I did come across this but was only able to reproduce it a couple of times, now it no longer appears to be reproducible, will update again if I can reproduce this reliably.
Comment #8
spokjeI can reproduce it when saving a workflow which has states, but no transitions on Drupal 9.2.1 . Will circle back later to make a failing test for this.
Comment #9
spokjeComment #10
dhirendra.mishra commentedHere re-rolled patches against 9.3.x
Comment #11
spokjeComment #12
spokjeNewly created MR has patches 2899872-10.patch and 2899872-test_only_should_fail.patch combined.
Comment #14
spokjeComment #16
spokjeFail was expected (since it was a test_only_should_fail.patch), let's see if the MR makes TestBot happy
Comment #17
spokjeAll green :)
Comment #18
spokje- Rebased MR on
9.4.x-dev- Merged latest commits
Comment #21
smustgrave commentedbefore testing can you update the MR to point to 9.5.x or rebase it? Currently it's saying it's not mergable.
One reason I don't like the MR. Could be easily fixed via patches but MR no one can edit them just push code.
Comment #23
spokjeYou can't always get what you want
(But if you try sometime you'll find
You get what you need)
Anyway: Added a 9.5.x MR and made the 9.4.x more up-to-date.
I like MRs, one reason: The pretty colors when showing the changes. :)
Comment #24
smustgrave commentedTried testing the issue before the patch
Created a new workflow which came with draft and published states and some transitions
Manually deleted the transitions so I have 0 now
But don't seem to be able to delete the draft and published states
And I'm not seeing an error about there being no transitions.
Is there a step I'm missing?
Comment #25
smustgrave commentedMoving PNMI for #24
Comment #31
spokjeCan't reproduce in the UI,
However fail-test still fails and updated MR still passes.
Unsure what to do, TBH being almost 2 years ago after the first NR (all other activity are rerolls for new branches), I don't really care anymore at this time.
Comment #32
smustgrave commentedHopefully didn't discourage anyone.
But if the bug can be reproduced please reopen updating issue summary with steps to reproduce.
Thanks!