Problem/Motivation
As described in a related core issue (#3342398: Path module calls getInternalPath without checking if the url is routed) I'm using a bundle class to override the toUrl() method on a particular node type. In particular, there's a link field that, if populated, will be used by the toUrl() method. The reason is that we want to allow cards to link to internal or external links (or no link whatsoever) as elegantly as possible.
The redirect_form_node_form_alter function is triggering the following exception:
UnexpectedValueException: Unrouted URIs do not have internal representations. in Drupal\Core\Url->getInternalPath()
Steps to reproduce
Use a bundle class with an override for toUrl that results in an unrouted uri for the node.
Proposed resolution
In addition to checking $entity->isNew() also check for $entity->toUrl()->isRouted().
Remaining tasks
User interface changes
N/A
API changes
N/A
Data model changes
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | redirect-unrouted-3342409-15.patch | 597 bytes | mighty_webber |
| #2 | redirect-unrouted-3342409-2.patch | 622 bytes | danflanagan8 |
Issue fork redirect-3342409
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
danflanagan8Here's a hopefully inoffensive patch.
Comment #3
dpiThanks for the patch, just what I needed.
Comment #6
mlncn commentedWorking, and the code is a straightforward minimal validity check.
Comment #7
mlncn commentedFrustratingly, instead of being committed, this now needs a re-roll :-/
Comment #12
dpiPushed 8.x-1.x to fork repo so the diff isnt 73 pages long. Back to one line.
Comment #13
mlncn commentedAh so that is what the problem is. Wherever that is documented i must always get that wrong, despite having tried in the past both with manual instructions and the rebase button in GitLab; it had seemed the catch-up rebase itself was the problem. Thanks. Also thought i had fixed it in https://git.drupalcode.org/project/redirect/-/merge_requests/164.diff (in that it was one line and useable, at least).
Either way, despite the maddening fork PLUS branch setup of Drupal issues, yes straightforward re-roll (the lines above had been changed to be better self-documentation) and back to RTBC.
Comment #14
dpiYeah, I'm sure this workflow quirk causes a tonne of unnecessary rebases and new MR's being created
Comment #15
mighty_webber commentedPatch for Drupal 10.4.9