When using tokens in a path alias similar to [node:menu-link:parent:url:path]
and the parent menu link is an external URL, Url::getInternalPath()
throws "Drupal\Core\Entity\EntityStorageException: Unrouted URIs do not have internal representations."
Steps to reproduce:
- Create a menu link that is an external (i.e, unrouted) URL.
- Create a pathauto pattern similar to the above and assign to a content type.
- Create content of the type chosen above and assign it as a child of the unrouted menu item.
- Save the node and the exception is thrown.
I will attach a patch that appears to address the issue, although I have not tested it thoroughly. Also, this patch silently fails to tokenize the path (instead it is left as '/'), as I am not certain what the desired behavior is in this case. Worth discussing I think.
Comment | File | Size | Author |
---|---|---|---|
#2 | url_token_exception-2828603-1.patch | 738 bytes | acy76 |
|
Comments
Comment #2
acy76 CreditAttribution: acy76 at Lullabot commentedPatch attached, please review.
Comment #3
SpadXIII CreditAttribution: SpadXIII at ezCompany commentedThis patch seems to have solved an issue for me as well. I have a url pattern set up as "[node:menu-link:parent:url:path]/[node:title]" and saving a node (using a hook_update_N) that follows this pattern threw an error in the console.
Not marking it RBTC, as I'm still unsure about further implications. As far as I could see, there aren't any in my project.
Comment #4
miro_dietikerThis is imho pretty easy to trigger in common scenarios and the application dies. Thus seems like a major issue to me?
Comment #6
BerdirYeah, decided to commit this, but would be nice to have test coverage, so keeping open for that.
Comment #7
miro_dietiker