Updating from 1.0 to 1.1 breaks all routes on nodes with a workflow attached (and probably terms as well?) giving a wsod on viewing. Error is Symfony\Component\Routing\Exception\RouteNotFoundException: Route "entity.node.workflow_history" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 202 of core/lib/Drupal/Core/Routing/RouteProvider.php).
This is likely due to the commit here https://www.drupal.org/project/workflow/issues/2584953#comment-12570162
Looking into how this might be fixed. Am guessing routes need to be changed in the router table
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 2969569-6.patch | 752 bytes | el1_1el |
Comments
Comment #2
johnvDoes flushing the caches help?
Comment #3
el1_1el commentedNo. I also tried rebuilding routes. Then I got distracted with an unrelated issue and couldn't debug further. Reverting to 1.0 "fixes" the problem. I'll post back when I know more.
Comment #4
el1_1el commentedIn src/Plugin/Derivative/WorkflowLocalTask.php in the method getDerivativeDefinitions, if I loop through $fields and add the field name ($fields[$key]) to the route_name it works again.
ex
This is obviously wrong, and gives the wrong fieldname if its not the last workflow field set.
Trying to dig into derivative routes to find a correct solution but posted in case other might have the issue or know more.
Comment #5
el1_1el commentedHere is a patch that fixes it, but might introduce errors if someone has multiple workflows on a single entity so Im not uploading for testing yet.
Only other option I can think of would be to load the entity and check for the presence of the field being loaded. Which probably would not occur within the RouteSubscriber->alterRoutes or in WorkflowLocalTask->getDerivativeDefinitions
Comment #6
el1_1el commentedSo after a lot of manual testing on this, it looks to me like the
entity.$entityTypeId.workflow_historyroute is never registered because I have 3 workflow fields on 3 different bundles.
Since there are no checks for bundles, and I have 3 fields, this line
if (count($fields) < 2) {in src/Routing/RouteSubscriber.php alterRoutes method prevents the workflow_history route from registering and only registers routes as
entity.$entityTypeId.workflow_history.$field_nameand i get the fatal error.I attached a simple patch to always register the workflow_history route in the router table preventing the fatal error.
Of note, this does not allow for entities with multiple workflow fields to have multiple tabs associated with each workflow.
However, when i tried that (see comment 4 and change
$this->derivatives["entity.$entity_type_id.workflow_history"] = [to
$this->derivatives["entity.$entity_type_id.workflow_history.$fieldname"] = [it would show tabs for every workflow field on every bundle and would not route to the correct associated workflow regardless.
I also tried adding 2 more workflow fields and associated them with new workflows on a single bundle. Even manually typing the second fieldname (ie node/nid/workflow/field_name) still brought me to the first workflow.
So I'm wondering if https://www.drupal.org/project/workflow/issues/2584953 might need more work.
Comment #8
johnvI committed your proposal.
Indeed, your usecase is not completely satisfied: there is no history tab for each workflow field, only a route.
This is documented in the code.
You may open a new issue for this. (supplort for multiple fields s an ongoing task in D8)
Comment #10
johnvComment #11
johnv