Using Drupal 8.5.1 and latest dev version of Workflow. Successfully set up a workflow with access and tranasitions via the UI. Successfully added Workflow fields to Content Types. Successfully transitioned Content with Workflow fields in Content Type.
Issue: Exported Configuration via the UI. When attempting import using:
drush cim --partial --no-halt-on-error --source=../config/sync -y
I get the following error:
Argument 1 passed to Drupal\workflow\Entity\WorkflowConfigTransition::setWorkflow() must be an instance of Drupal\workflow\Entity\Workflow, null given, called in [error]
.../docroot/modules/contrib/workflow/src/Entity/WorkflowConfigTransition.php on line 72 and defined WorkflowTypeAttributeTrait.php:37
Fatal error: Call to a member function id() on null in .../docroot/modules/contrib/workflow/src/WorkflowTypeAttributeTrait.php on line 38
Drush command terminated abnormally due to an unrecoverable error.
Configuration files attached.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | interdiff_12-15.txt | 683 bytes | ankit agrawal |
| #15 | workflow-config-transition-2961558-15.patch | 2.05 KB | ankit agrawal |
| #12 | interdiff_10-12.txt | 695 bytes | balazswmann |
| #12 | workflow-fix-config-deps-2961558-12-D8.patch | 1.56 KB | balazswmann |
| #10 | workflow-fix-config-deps-2961558-10-D8.patch | 1.32 KB | balazswmann |
Comments
Comment #2
johnvIs it possible that the yml files are parsed in the wrong order?
It should be : first workflow, then workflow.state , then workflow.transition.
In any case, I see that the values for 'label' and 'module' are noeer filled. I am not sure if this is an error.
Comment #3
sassafrass commentedHi...and thank-you for the quick response.
I am not sure what order the files are being parsed in since it is controlled by the drush command. Is there a way to control the order other than doing one file import at a time?
Comment #4
johnvI don't know. I'll try and import one by one.
Comment #6
johnvPlease try latest dev version.
Comment #7
estoyausenteSame error here with the latest version (that include this commit). I not sure the problem but the code doesn't seem to resolve it. I'm doing the import using drush.
I'm not sure how can help you to resolve, if I can do something just let me know.
Comment #8
estoyausenteI was debuggin and in the
WorkflowConfigTransition.phpconstructor class, the $state cannot find the associated Workflow.Your change doesn't resolve the problem because the setWorkflow method needs a Workflow Class as a input param and NULL is not a valid input. Furthermore, with the new change we are trying to do Null->wid = '' and it will throw an error too. I think that the problem is in the call.
I tested something like this:
but it doesn't work. The import finish correctly but the states aren't be created successfully. I don't know where is the deep problem, I'm not sure how the Import process works :S
Comment #9
balazswmann commentedI can confirm this bug. Saving settings on the UI works well, but the configuration import fails.
Comment #10
balazswmann commentedThe problem was that config dependencies were not defined for WorkflowState and WorkflowConfigTransition entities. The attached patch solves this problem.
Comment #11
balazswmann commentedComment #12
balazswmann commentedThe previous patch causes an infinite loop at the WorkflowState entity. Fixed patch attached.
Comment #13
ankit agrawal commented@balazswmann Thank you for sharing the patch. I tried the above patch, and re-exported the configuration after saving the workflow form again, however still getting the following error on site-rebuild:
TypeError: Argument 1 passed to Drupal\workflow\Entity\WorkflowConfigTransition::setWorkflow() must be an instance of Drupal\workflow\Entity\Workflow, null given, called in modules/contrib/workflow/src/Entity/WorkflowConfigTransition.php on line 79 in modules/contrib/workflow/src/WorkflowTypeAttributeTrait.php on line 37 #0 modules/contrib/workflow/src/Entity/WorkflowConfigTransition.php(79): Drupal\workflow\Entity\WorkflowConfigTransition->setWorkflow(NULL)Comment #14
ankit agrawal commentedComment #15
ankit agrawal commentedRe-rolled the patch with updated changes:
Comment #16
ankit agrawal commentedComment #17
johnvComment #19
johnvPlease try latest dev version.
- The symptom (Workflow = NULL) is removed by changing function setWorkflow(Workflow $workflow = NULL);
- The root cause is tackled by adding function calculateDependencies();
Thanks so far, hope this version works.
Comment #21
laurent.lacote commentedHi all ;)
First off, thanks to all maintainers for this module!
I find it really much better than its counterpart that was integrated to core, notably for the very lax coupling with revisioning system, the ability to stack several workflows on a same content and the ability to make workflow transitions independantly from node access. :)
I have however to be the bearer of bad news: the current bug still exists, and hard.
Steps to reproduce.
1. Activate module in 1.1 version (workflow + workflow UI, no need to activate Access).
2. Create one basic workflow with at least two states and one transition.
3. Try to export one configuration in UI (either single export or full archive): in all configuration yml files, the key "dependencies" stays empty at the very least for transitions configurations (from memory also true for state configuration but away from my work computer right now):
"dependencies: {}".
Whereas in my comprehension dependencies should follow this chain.
Module <- workflow <- state(s) -< transition.
Unfortunately, I currently have no idea how to help analyse the cause. This uses up many Drupal and POO concepts I'm not (yet) familiarized (enough) with.
My comprehension so far is that the problem may come from inside the calculateDependencies, either from the private methods getFromState and similar or the getDependencyConfigName, since the problem persists although those were added and supposed to fix it.
While I'm far from being an expert in development, I'll be happy to help troubleshooting this as long as you give me some direction in which to look for.
Thanks in advance!
Best regards,
Laurent Lacôte
Comment #22
johnvPlease use dev version. The error occurs in 1.1, and is fixed in the upcoming 1.2 release.
Comment #23
benjaminbradley commentedHi, can we get a new release of this module please? This issue has been fixed for a year but there's no new release yet.
Comment #24
johnv