Symfony\Component\Routing\Exception\InvalidParameterException: Parameter "node_revision" for route "node.revision_revert_default_confirm" must match "[^/]++" ("" given) on thunder/modules/thunder_workflow/src/ThunderWorkflowFormHelper.php

Created on 7 February 2024, 11 months ago

Problem/Motivation

We get a weird WSOD when trying to exit out of preview mode. The error says:
Symfony\Component\Routing\Exception\InvalidParameterException: Parameter "node_revision" for route "node.revision_revert_default_confirm" must match "[^/]++" ("" given) to generate a corresponding URL.
We tracked it down to line 249 on

```
$route_info = Url::fromRoute('node.revision_revert_default_confirm', [
'node' => $entity->id(),
'node_revision' => $entity->getRevisionId(),
]);
```

In this edge-case, $entity->getRevisionId() does not return a valid revision id which breaks the doGenerate() function in UrlGenerator.php for the route `node.revision_revert_default_confirm` on `thunder_article.routing.yml`

Steps to reproduce

Create a node (page)
Save it as published. (OK)
Preview (OK)
Exit preview (OK)
Edit it, save it as draft. (OK)
Edit it again, without saving preview. (OK)
Exit Preview (FAILS)

Proposed resolution

Adding defensive code:

```
$route_info = Url::fromRoute('node.revision_revert_default_confirm', [
'node' => $entity->id(),
'node_revision' => $entity->getRevisionId() ?? 0,
]);
```

Remaining tasks

Validate the problem and the solution

User interface changes

N/A

API changes

N/A

Data model changes

N/A

🐛 Bug report
Status

Active

Version

7.1

Component

Code

Created by

🇲🇽Mexico rmontero CMDX

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024