Problem/Motivation

If you attempt to install Drupal against a database with existing content, you'll receive this obtuse error, which does not explain how to recover:

Symfony\Component\Routing\Exception\RouteNotFoundException: Route "<front>" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 147 of /private/var/www/git/drupal8/docroot/drupal/core/lib/Drupal/Core/Routing/RouteProvider.php).

To replicate:
Install drupal 8 to new database.
Remove pointer to database by copying default.settings.php to settings.php
Drupal attempts to re-install.
Using original database connection in install.php creates exception

Additional uncaught exception thrown while handling exception.
Original
Symfony\Component\Routing\Exception\RouteNotFoundException: Route "<front>" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 147 of /private/var/www/git/drupal8/docroot/drupal/core/lib/Drupal/Core/Routing/RouteProvider.php).
Drupal\Core\Routing\RouteProvider->getRouteByName('')
Drupal\Core\Routing\UrlGenerator->getRoute('')
Drupal\Core\Routing\UrlGenerator->generateFromRoute('', Array, Array)
Drupal::url('')
template_preprocess_page(Array)
template_preprocess_maintenance_page(Array)
template_preprocess_install_page(Array, 'install_page', Array)
_theme('install_page', Array)
Drupal\Core\Theme\ThemeManager->render('install_page', Array)
drupal_render(Array)
Drupal\Core\Page\DefaultHtmlPageRenderer::renderPage(Array, 'Installing Drupal', 'install', Array)
install_display_output(Array, Array)
install_drupal()
Additional
Symfony\Component\Routing\Exception\RouteNotFoundException: Route "<front>" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 147 of /private/var/www/git/drupal8/docroot/drupal/core/lib/Drupal/Core/Routing/RouteProvider.php).
Drupal\Core\Routing\RouteProvider->getRouteByName('')
Drupal\Core\Routing\UrlGenerator->getRoute('')
Drupal\Core\Routing\UrlGenerator->generateFromRoute('', Array, Array)
Drupal::url('')
template_preprocess_page(Array)
template_preprocess_maintenance_page(Array)
template_preprocess_install_page(Array, 'install_page', Array)
_theme('install_page', Array)
Drupal\Core\Theme\ThemeManager->render('install_page', Array)
drupal_render(Array)
Drupal\Core\Page\DefaultHtmlPageRenderer::renderPage(Array, 'Error', 'install', Array)
install_display_output(Array, Array)
_drupal_log_error(Array, 1)
_drupal_exception_handler(Object)

Proposed resolution

Print out a simple message like Drupal 7 used to do.

Remaining tasks

User interface changes

API changes

Original report by @richardcanoe

Comments

richardcanoe’s picture

Issue tags: +Amsterdam2014
larsmw’s picture

Issue summary: View changes

I can confirm this on a Debian 7 setup.
php : 5.4.4-14+deb7u9
Mysql-server : 5.5.37

This is apearing when installing to a non-empty database.

richardcanoe’s picture

Issue summary: View changes
richardcanoe’s picture

Issue summary: View changes
larsmw’s picture

This happens when you try to install onto a nonempty database. So instead of telling that there is content in the database the installer throws this exception.

The expected behavior might be to get a warning that the database is not empty and ready for install. Is it supposed that you should be able to install over a non-empty database? Or should there be a meaningful error message to guide the user to select another database?

yanniboi’s picture

Status: Active » Needs work

I agree with @larsmw.

The installer should not attempt to install on a used database, but should display an error message asking users to create a new (clean) database.

gmasky’s picture

I am getting this error while trying to install on a new DB https://www.drupal.org/node/2348817

richardcanoe’s picture

Issue summary: View changes

AlreadyInstalledException exists, but is not being called

larsmw’s picture

I think this should be handled in 'install.core.inc' file in the install_begin_request(&$install_state) function around line 340 where there is a check for which tables exists in the database!?
Does this assumption sound right?

larsmw’s picture

I breefly discussed this with @Crell, and he suggested to make an Install Task to check the state of the database and on base of that give an apropriate message to the user.

larowlan’s picture

Status: Needs work » Active
Issue tags: +Needs tests

The issue is the URL generation in the maintenance page is wrong when the site is in such a low level install state.

miraj9093’s picture

I am getting the same errror in installation in clean new Database. I am using drupal 8-0 beta , Apache-php-mysql with windows.

webchick’s picture

Priority: Normal » Major

This should be at least major IMO, if not critical.

webchick’s picture

Issue summary: View changes

Updating the issue summary a bit.

webchick’s picture

Issue summary: View changes
webchick’s picture

Title: Front page route not found Exception when installing drupal and connecting to existing database » Regression: 'Front page route not found' Exception when installing Drupal against an existing database
Priority: Major » Critical

And yeah, given that D7 used to handle this condition fine, critical. One last update; sorry for the noise.

myforgedoteu’s picture

Assigned: Unassigned » myforgedoteu

Currently adding an install task to check if the database is already installed and throw the exception in AlreadyInstalledException
Preventing the script to try to run over the already installed database and throw this routing error

webchick’s picture

It'd be sweet if this could somehow be done without adding a new step to the installer. We've taken care to try and *remove* steps from the installer in this release elsewhere. If it can't though, so be it.

myforgedoteu’s picture

it might be done without a new step in fact, will have first to fix the routing error, then it should process the regular path of the installer and reach the error thrown by AlreadyInstalledException

dawehner’s picture

Status: Active » Needs work
StatusFileSize
new3.29 KB
new836 bytes

There are several problems involved here:

  • The code path for rendering a maintenance page (used in the installer) should try to avoid to call to the database
  • \Drupal::url('<front>'); does not follow this rule
  • The interface UrlGenerator->generate() allows you to pass along the full route object as $name, so you don't have to load it from the db. this avoid a couple of problems
  • This still for example reasons adds the following message:
    Notice: Undefined index: entity_test in module_set_weight() (line 230 of core/includes/module.inc).
    module_set_weight('standard', 1000)
    install_finished(Array)
    install_run_task(Array, Array)
    install_run_tasks(Array)
    install_drupal()
    Drupal\Component\Plugin\Exception\PluginNotFoundException: The "entity_test_mulrev" entity type does not exist. in Drupal\Core\Entity\EntityManager->getDefinition() (line 243 of core/lib/Drupal/Core/Entity/EntityManager.php).
    Drupal\Core\Entity\EntityManager->getDefinition('entity_test_mulrev')
    Drupal\Core\Entity\EntityManager->getHandler('entity_test_mulrev', 'views_data')
    views_views_data()
    call_user_func_array('views_views_data', Array)
    Drupal\Core\Extension\ModuleHandler->invokeAll('views_data')
    Drupal\views\ViewsData->getData()
    Drupal\views\ViewsData->get('block_content')
    Drupal\views\Plugin\Derivative\ViewsEntityRow->getDerivativeDefinitions(Array)
    Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives(Array)
    Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions()
    Drupal\Core\Plugin\DefaultPluginManager->findDefinitions()
    Drupal\Core\Plugin\DefaultPluginManager->getDefinitions()
    Drupal\views\Views::fetchPluginNames('row', 'feed', Array)
    Drupal\views\Plugin\views\display\Feed->initDisplay(Object, Array)
    Drupal\views\DisplayBag->initializePlugin('feed_1')
    Drupal\Component\Plugin\PluginBag->get('feed_1')
    Drupal\views\DisplayBag->get('feed_1')
    Drupal\Component\Plugin\PluginBag->valid()
    Drupal\views\Views::getApplicableViews('uses_route')
    Drupal\views\EventSubscriber\RouteSubscriber->getApplicableViews()
    Drupal\views\EventSubscriber\RouteSubscriber->getViewsDisplayIDsWithRoute()
    Drupal\views\EventSubscriber\RouteSubscriber->routes()
    call_user_func(Array)
    Drupal\Core\Routing\RouteBuilder->rebuild()
    install_finished(Array)
    install_run_task(Array, Array)
    install_run_tasks(Array)
    install_drupal()
    
myforgedoteu’s picture

StatusFileSize
new3.13 KB

as @dawehner started, the call to the front page might be fixed and now while testing the installer throw no routing errors while trying to install it on the same database.

But still need to modify the installer to prevent the installation on the same database. We are still able to install on the same one after patching the url routing.

myforgedoteu’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 21: 2349441-21-1.patch, failed testing.

cilefen’s picture

Status: Needs work » Needs review
StatusFileSize
new3.19 KB

Reroll of #21. The situation in #23 is the same.

Status: Needs review » Needs work

The last submitted patch, 24: 2349441-24.patch, failed testing.

yannickoo’s picture

I could apply your patch but got the following error:

Additional uncaught exception thrown while handling exception.

Original

Symfony\Component\Routing\Exception\RouteNotFoundException: Route "<current>" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 149 of /vagrant/code/d8/core/lib/Drupal/Core/Routing/RouteProvider.php).

Drupal\Core\Routing\RouteProvider->getRouteByName('')
Drupal\Core\Routing\UrlGenerator->getRoute('')
Drupal\Core\Routing\UrlGenerator->getPathFromRoute('', Array)
Drupal\Core\Url->getInternalPath()
system_theme_suggestions_html(Array)
call_user_func_array('system_theme_suggestions_html', Array)
Drupal\Core\Extension\ModuleHandler->invokeAll('theme_suggestions_html', Array)
Drupal\Core\Theme\ThemeManager->theme('html', Array)
Drupal\Core\Theme\ThemeManager->render('html', Array)
Drupal\Core\Render\Renderer->render(Array)
Drupal\Core\Render\BareHtmlPageRenderer->renderBarePage(Array, 'Installing Drupal', 'install_page', Array)
install_display_output(Array, Array)
install_drupal()

Additional

LogicException: A stray drupal_render() invocation with $is_root_call = TRUE is causing bubbling of attached assets to break. in Drupal\Core\Render\Renderer->render() (line 335 of /vagrant/code/d8/core/lib/Drupal/Core/Render/Renderer.php).

Drupal\Core\Render\Renderer->render(Array, 1)
Drupal\Core\Render\BareHtmlPageRenderer->renderBarePage(Array, 'Error', 'install_page', Array)
install_display_output(Array, Array)
_drupal_log_error(Array, 1)
_drupal_exception_handler(Object)
xjm’s picture

Status: Needs work » Closed (duplicate)