I have not yet been able to fully diagnose this issue (hence the clumsy issue title), so I will describe it by its symptoms as first reported in #2773975: Error while installing checklist module: Checklist API lets other modules declare checklists by implementing a hook. Those checklists are turned into pages with routes created by a route subscriber in the API module. Client modules optionally provide their own menu links for those routes. Depending on how you install the modules, however, you get a RouteNotFoundException from the menu links. Specifically, the problem occurs when two conditions are true: 1) you are installing via the web UI, and 2) you install the modules one at a time (the API module in one step and a client module in a succeeding step). It works fine via Drush or Drupal Console, and the web UI works fine if you install both modules in the same step. I would assume the defect to be in my modules, were it not for the fact that they work perfectly if you just install them in the same step--a detail so seemingly irrelevant that it makes me suspect core.

Comments

TravisCarden created an issue. See original summary.

cilefen’s picture

crag2012’s picture

Have been attempting to get to grips with drupal for about 4 years (from6)
installation on G580 Lenovo, win 8.1, xampp-win32-7.0.9-1-VC14-installer (worked fine)
installing first core drupal-8.1.10 then drupal-8.1.9 both results same
although php.ini max_execution_time extended to 120s from 30 does report a timing error, if rerun from http://localhost/drupal/core/install.php
the error occurs

Seems a repeat of previous entries,
*****output**********
Additional uncaught exception thrown while handling exception.

Original

Symfony\Component\Routing\Exception\RouteNotFoundException: Route "" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 187 of C:\xampp\htdocs\drupal\core\lib\Drupal\Core\Routing\RouteProvider.php).

Drupal\Core\Routing\RouteProvider->getRouteByName('') (Line: 425)
Drupal\Core\Routing\UrlGenerator->getRoute('') (Line: 121)
Drupal\Core\Routing\UrlGenerator->getPathFromRoute('', Array) (Line: 68)
Drupal\Core\Render\MetadataBubblingUrlGenerator->getPathFromRoute('', Array) (Line: 772)
Drupal\Core\Url->getInternalPath() (Line: 99)
Drupal\Core\Path\PathMatcher->isFrontPage() (Line: 254)
system_theme_suggestions_html(Array)
call_user_func_array('system_theme_suggestions_html', Array) (Line: 402)
Drupal\Core\Extension\ModuleHandler->invokeAll('theme_suggestions_html', Array) (Line: 230)
Drupal\Core\Theme\ThemeManager->render('html', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array, 1) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, 1) (Line: 139)
Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 140)
Drupal\Core\Render\Renderer->renderRoot(Array) (Line: 66)
Drupal\Core\Render\BareHtmlPageRenderer->renderBarePage(Array, Object, 'install_page', Array) (Line: 76)
Drupal\Core\ProxyClass\Render\BareHtmlPageRenderer->renderBarePage(Array, Object, 'install_page', Array) (Line: 998)
install_display_output(Array, Array) (Line: 154)
install_drupal(Object) (Line: 39)
Additional

Symfony\Component\Routing\Exception\RouteNotFoundException: Route "" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 187 of C:\xampp\htdocs\drupal\core\lib\Drupal\Core\Routing\RouteProvider.php).

Drupal\Core\Routing\RouteProvider->getRouteByName('') (Line: 425)
Drupal\Core\Routing\UrlGenerator->getRoute('') (Line: 277)
Drupal\Core\Routing\UrlGenerator->generateFromRoute('', Array, Array, 1) (Line: 105)
Drupal\Core\Render\MetadataBubblingUrlGenerator->generateFromRoute('', Array, Array, ) (Line: 543)
Drupal::url('') (Line: 1356)
template_preprocess_page(Array) (Line: 1458)
template_preprocess_maintenance_page(Array) (Line: 1487)
template_preprocess_install_page(Array, 'install_page', Array) (Line: 287)
Drupal\Core\Theme\ThemeManager->render('install_page', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 468)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 90)
__TwigTemplate_3ca16517bf3776375e3e02ac162becccac1bbe4172908107101d5ed2dce97277->doDisplay(Array, Array) (Line: 381)
Twig_Template->displayWithErrorHandling(Array, Array) (Line: 355)
Twig_Template->display(Array) (Line: 366)
Twig_Template->render(Array) (Line: 64)
twig_render_template('core/themes/classy/templates/layout/html.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('html', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array, 1) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, 1) (Line: 139)
Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 140)
Drupal\Core\Render\Renderer->renderRoot(Array) (Line: 66)
Drupal\Core\Render\BareHtmlPageRenderer->renderBarePage(Array, 'Error', 'install_page', Array) (Line: 76)
Drupal\Core\ProxyClass\Render\BareHtmlPageRenderer->renderBarePage(Array, 'Error', 'install_page', Array) (Line: 998)
install_display_output(Array, Array, Array) (Line: 263)
_drupal_log_error(Array, 1) (Line: 564)
_drupal_exception_handler(Object)
*******end of output***********

not sure what to do next?

cilefen’s picture

@crag2012 I am not sure the exception you saw is anything to do with this particular issue. There have been issues with Drupal requirements and the default setup of things like xampp. Please check the requirements and open another issue for what you have seen.

tim.plunkett’s picture

Priority: Major » Normal
Status: Active » Postponed (maintainer needs more info)

Does the menu link providing module explicitly depend on the route providing module?
Can you give more specific steps to reproduce?

traviscarden’s picture

Status: Postponed (maintainer needs more info) » Active

Yes, the module providing the menu link (checklistapiexample) declares a dependency on the module providing the route (checklistapi). And the dependency is definitely already installed when the problem manifests.

To reproduce using Checklist API:

  1. Download checklistapi 8.x-1.0.
  2. Enable Checklist API module via the web UI. (It must be via the web UI. In my testing, the problem does not manifest using Drush or Drupal Console.)
  3. Enable Checklist API Example module via the web UI.
  4. Get RouteNotFoundException.

You can browse the afflicted code on GitHub, if you like: https://github.com/TravisCarden/checklistapi/tree/8.x-1.0. Since that tag I have temporarily worked around the issue by manually declaring the route in the example module in addition to dynamically declaring it in the API module.

tim.plunkett’s picture

Reproduced, debugging.

tim.plunkett’s picture

checklistapi_get_checklist_info() uses drupal_static to store the list of definitions.
ModuleInstaller::install() does not clear all statics, it only runs drupal_static_reset('system_rebuild_module_data');
So when your \Drupal\checklistapi\Routing\ChecklistapiRouteSubscriber::routes() runs, it is given stale info.

This is the correct fix for checklistapi.

diff --git a/checklistapi.module b/checklistapi.module
index 50c8d93..b15a2f4 100644
--- a/checklistapi.module
+++ b/checklistapi.module
@@ -103,6 +103,13 @@ function checklistapi_get_checklist_info($id = NULL) {
 }
 
 /**
+ * Implements hook_module_preinstall().
+ */
+function checklistapi_module_preinstall($module) {
+  drupal_static_reset('checklistapi_get_checklist_info');
+}
+
+/**
  * Implements hook_help().
  */
 function checklistapi_help($route_name, RouteMatchInterface $route_match) {

Or, switch from an info hook to plugins, and then the call to \Drupal::getContainer()->get('plugin.cache_clearer')->clearCachedDefinitions(); will take care of everything for you :)

traviscarden’s picture

Category: Bug report » Support request
Status: Active » Fixed

Thank you very much, @tim.plunkett!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.