When you have the workflow module [https://www.drupal.org/project/workflow] installed and you visit the states page for a worflow (something like http://mysite.dev/admin/config/workflow/workflow/workflow_name/states) I am getting a WSD and an error log of:
Symfony\Component\Routing\Exception\InvalidParameterException: Parameter "workflow_state" for route "entity.workflow_state.clone_form" must match "[^/]++" ("" given) to generate a corresponding URL. in Drupal\Core\Routing\UrlGenerator->doGenerate() (line 193 of /vagrant/app/core/lib/Drupal/Core/Routing/UrlGenerator.php).
In this case I think it doesn't make sense to have the workflow_state being able to be cloned. My first thought is just to do something like this:
/**
* Implements hook_entity_type_alter().
*/
function entity_clone_entity_type_alter(array &$entity_types) {
foreach ($entity_types as $entity_type_id => $entity_type) {
if ($entity_type->getLinkTemplate('edit-form')) {
$entity_type->setLinkTemplate('clone-form', "/entity_clone/$entity_type_id/{{$entity_type_id}}");
}
}
}
Note the check for an `edit-form` which workflow_state doesn't have and I would expect everything that wants to be 'clonable' should have.
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | 2866889-21.patch | 1.27 KB | upchuk |
| #13 | workflow-state-break-286688-13.patch | 704 bytes | brolad |
| #2 | workflow-state-break-286688-2.patch | 635 bytes | mikejw |
Issue fork entity_clone-2866889
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
mikejw commentedComment #4
johnvAs the maintainer of the Workflow module, I think the proposed patch is the correct way to solve the problem.
In a more generic way, EntityClone might be disabled for any ConfigEntityBase (WorkflowState extends ConfigEntityBase )
Comment #5
socialnicheguru commentedThis works
Comment #6
socialnicheguru commentedThis worked for me
Comment #7
vpeltot commentedAll tests are failed with the latest patch.
This issue status cannot be RTBC.
Please correct the patch and/or tests before changing the status.
Comment #8
mars0test commentedHi
I've try to reproduce the problem, but when I enable workflow I don't find the error as you describe.
Is it always active ? or something has fix the bug ?
Comment #9
mars0test commentedComment #10
noita commentedThis is a combination with entity_clone module. I have the same issues and the workaround is to disable module entity_clone when you have finish to use workflow.
Comment #11
noita commentedI have activated : workflow, workflow_access, workflow_operations and workflow_ui + entity_clone
Comment #12
donaldp commentedHi. I've just come across the same or similar problem with Entity clone and the workflow module. In my case the error causing the WSD is different.
Fatal error: Call to a member function cachePerPermissions() on boolean in /......./modules/contrib/workflow/src/WorkflowAccessControlHandler.php on line 116This was caused when trying to access the Workflow tab of existing content. /node/76/workflow
The stack trace shows the Entity clone code being called as the crash occurs. Disabling the Entity clone module allows the Workflow tab to appear correctly.
Adding the suggested entiity_type_alter hook does not seem to help in my case. I will have to dig further as this seems to be a different issue?
The site is running fully up to date core 8.6.13 and other modules.
With some further investigation I think that this is a bug in the Workflow module not the Entity clone module so going to look there for a solution.
The issue is that access can return an object of boolean and the Workflow access module assumes that it has an object whereas it actually gets a boolean value when using checking workflow_transition "clone" operations.
I've now raised this as a new issue with a patch to fix it. https://www.drupal.org/project/workflow/issues/3046122
Comment #13
brolad commentedComment #14
caspervoogt commentedTried the patch from #13 which solved the conflict with Workflow's "/admin/config/workflow/workflow/{workflowname}/states" page(s) for me.
Comment #17
dpiRe-rolled and pushed as MR.
Comment #18
finex commentedThank you, the patch seems fine.
Comment #19
sorlov commentedThanks, patch works fine.
Comment #20
KondratievaS commentedComment #21
upchuk commentedOK, so a couple of things here.
1. Definitely the solution is not to remove entity clone logic from config entities.
2. I'm not sure about completely removing the cloning from the entity types without the "edit-form" link template. There might be cases when this is needed. Not to mention potential BC. I think allowing to alter the list of entity types, or even maybe configuring the entity types that can be cloned, would be better for such cases.
3. Regarding workflow state, I could not reproduce exactly that issue, but I found actually 3 things:
Comment #22
upchuk commentedComment #23
joevagyok commentedI agree with @Upchuk, we can't simply block the cloning of config entity types. I checked and the patch seem to address the issues mentioned above.
Comment #24
sinn commentedOriginal issue "http://mysite.dev/admin/config/workflow/workflow/workflow_name/states) I am getting a WSD and an error log of:" doesn't exist anymore since this path doesn't exist anymore. It was in https://www.drupal.org/project/workflow.
Regarding #21 "When going to the States page of a workflow, adding a new State via Ajax would fail" I couldn't reproduce the issue since have not found the possibility of adding new State via Ajax. Actually it is another issue, isn't related to original one.
Comment #26
upchuk commentedMerged.