Problem/Motivation
When an entity with an external canonical url is deleted an exception is thrown via redirect_entity_delete:
UnexpectedValueException: Unrouted URIs do not have internal representations. in Drupal\Core\Url->getInternalPath()
This is due to the call to $entity->toUrl('canonical')->getInternalPath() without checking whether the url is routed or not.
I believe this was introduced by #2888903: Delete redirects even the entity lacks the path field
Steps to reproduce:
* Install https://www.drupal.org/project/linky and redirect
* Add a managed link entity
* Try to delete the entity
Proposed resolution
Check the canonical url is routed before attempted to delete anything.
Remaining tasks
Code
Tests
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 2935026-4.patch | 1.24 KB | nikunjkotecha |
| #2 | 2935026-check-url-is-routed-2.patch | 690 bytes | acbramley |
Comments
Comment #2
acbramley commentedHere's the fix, still probably need tests for this delete hook and the fix as well though.
Comment #3
acbramley commentedComment #4
nikunjkotechaFor me same thing is happening but when disabling the module lightning_media.
Comment #5
pingwin4egComment #7
berdirThanks, committed. Fixed the comment, has nothing to do with uninstalling modules.
Comment #8
berdirComment #10
idebr commented#7 While this issue is not strictly related to uninstalling modules, the error (also) occurs when an entity type has a canonical link template but does not have a canonical route. This often happens with configuration entity types in the contrib space, such as Entity Browser. I am currently running into this issue with LDAP, see #2961668: LDAP configuration entity types define a canonical link template but do not have a canonical route
Comment #11
leisurman commentedI am getting this error when trying to edit any entity browsers. I can access the widget tab here. /admin/config/content/entity_browser/image_browser/widgets
The edit tab throws the error.
/admin/config/content/entity_browser/media_browser_ckeditor/edit
I have tried all of the patches from these issues:
https://www.drupal.org/project/redirect/issues/2932263
https://www.drupal.org/project/redirect/issues/2935026
https://www.drupal.org/project/redirect/issues/2888903
I tried upgrading Redirect Version: 8.x-1.4 to the dev version 8.x-1.x-dev. It did not fix the issue.
We are using Drupal Version 8.6.17, Lightning 8.x-3.207
Redirect Version: 8.x-1.4
Entity Browser version: 8.x-2.1
Comment #12
berdirThis issue was only about deleting, it was never a problem with editing. Most likely some other module is calling to Url(), you need to enable verbose error logging and check the backtrace.