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.

Command icon 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

mikejw created an issue. See original summary.

mikejw’s picture

Status: Active » Needs review
StatusFileSize
new635 bytes

Status: Needs review » Needs work

The last submitted patch, 2: workflow-state-break-286688-2.patch, failed testing.

johnv’s picture

Status: Needs work » Needs review

As 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 )

socialnicheguru’s picture

This works

socialnicheguru’s picture

Status: Needs review » Reviewed & tested by the community

This worked for me

vpeltot’s picture

Status: Reviewed & tested by the community » Needs work

All tests are failed with the latest patch.
This issue status cannot be RTBC.

Please correct the patch and/or tests before changing the status.

mars0test’s picture

Hi
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 ?

mars0test’s picture

Status: Needs work » Postponed (maintainer needs more info)
noita’s picture

This 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.

noita’s picture

I have activated : workflow, workflow_access, workflow_operations and workflow_ui + entity_clone

donaldp’s picture

Hi. 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 116

This 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

brolad’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new704 bytes
caspervoogt’s picture

Tried the patch from #13 which solved the conflict with Workflow's "/admin/config/workflow/workflow/{workflowname}/states" page(s) for me.

dpi made their first commit to this issue’s fork.

dpi’s picture

Re-rolled and pushed as MR.

finex’s picture

Thank you, the patch seems fine.

sorlov’s picture

Thanks, patch works fine.

KondratievaS’s picture

Status: Needs review » Reviewed & tested by the community
upchuk’s picture

StatusFileSize
new1.27 KB

OK, 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:

  • When going to the States page of a workflow, adding a new State via Ajax would fail due to the entity clone operation being added to a new state entity. Same error as reported here. Fixed in patch
  • Fixing the above, allows to clone an existing state. However, submitting the clone fails due to a redirect to the canonical URL of the workflow state entity. However, entity clone checks for the existence of the canonical link template on the state entity but then redirects to $entity->toUr() which "usually" is the canonical (except for config entities which is the workflow state where it defaults to "edit-form" and which it doesn't have). Fixed in the patch to redirect to the canonical properly.
  • HOWEVER, WorkflowState defines a canonical link template but not also a route for it! So this will still fail. And there is nothing I can about it here since that is a workflow issue. Entities that define a link template for canonical, should also define the route for that. There seems to be a meta issue about this #3216901: [Meta] Route "entity.workflow_state.canonical" does not exist
upchuk’s picture

Status: Reviewed & tested by the community » Needs review
joevagyok’s picture

Status: Needs review » Reviewed & tested by the community

I 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.

sinn’s picture

Original 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.

  • Upchuk committed 5140fa1 on 8.x-1.x
    Issue #2866889 by dpi, mikejw, Upchuk, Brolad, joevagyok, sinn: WSD on...
upchuk’s picture

Status: Reviewed & tested by the community » Fixed

Merged.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.