For my custom module, when add one of its pages to shorcuts list and then disable the module, get the following exception on all pages.
Symfony\Component\Routing\Exception\RouteNotFoundException: Route "some_module.config_list" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 150 of core/lib/Drupal/Core/Routing/RouteProvider.php).
The exception disappears when corresponding row is removed from database shortcut table.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | shortcut-route-not-found-2266325-7.patch | 2.5 KB | mr.baileys |
| #3 | shortcut-route-not-found-2266325-3.patch | 1.07 KB | mr.baileys |
Comments
Comment #1
kpv commentedComment #2
kpv commentedComment #3
mr.baileysI set out to automatically remove shortcut links to routes belonging to modules that are being uninstalled, but I don't know how to get a list of routes registered by any given module.
To advance this issue, here's a test that shows this bug. (setting to NR to run this test through the testbot, expecting a fail.)
Setting to major since uninstalling a module can break your entire site, and requires manually removing the shortcut link from the database to recover.
Comment #5
kpv commented#3 mr.baileys
I see two ways to solve the issue:
Imo, 2nd option is a better one.
Comment #6
kpv commentedComment #7
mr.baileys@kpv: thanks for the pointers!
Attached is a patch that should fix the original scope of this issue (uninstalling a module with routes for which one or more shortcut links exist no longer cause the site to break). However, this does not solve the full issue: routes can be added dynamically (for example through Views), and shortcut links pointing to those might still trigger an exception when the routes disappear (which is also why the router/shortcut-table solution outlined in #5.2 might not be the best approach).
For dynamic routes, I think we have no other option than to add a check to shorcut to ensure all links to be rendered point to a route that exists.
Setting to CNR to show that the patch fixes the "shortcut-breaks-on-module-uninstall"-issue, but this issue remains NW for the dynamic routes.
Comment #8
dawehnerMh, this really just works for static routes, not defined dynamically. An alternative implementation could be to fetch all the route names which are available and check with those
Comment #9
dawehnerSo .
Comment #10
tim.plunkettThis is absolutely a duplicate of an old issue, but I can't find it :(
Comment #11
dawehnerYeah I also remember that other one, but I thought it was already marked as fixed ...
Comment #12
kpv commented@tim.plunkett, @dawehner
#2277753: Shortcuts should handle missing routes elegantly seems to be the duplicate and #2200185: Router table is not cleared when modules are uninstalled deals with a similar issue.
Comment #13
gendoas commentedIn function shortcut_renderable_links() you may ensure that only available routes are listed. This does not remove items from disabled modules in database, but prevents errors.
Comment #16
dawehner#2277753: Shortcuts should handle missing routes elegantly seems to have more momentum.