Download & Extend

drupal_flush_all_caches() assumes a web request - "The service definition "router.builder" does not exist. "

Project:Drupal core
Version:8.x-dev
Component:base system
Category:bug report
Priority:major
Assigned:Unassigned
Status:closed (fixed)
Issue tags:symfony, WSCCI, wscci-hitlist

Issue Summary

#1606794: Implement new routing system added a new routing system, which is pulled out of drupal_container.
Something isn't being built early enough when using drush.

$ drush cc all
WD php: Symfony\Component\DependencyInjection\Exception\InvalidArgumentException: The service definition "router.builder" does not exist. in       [error]
Symfony\Component\DependencyInjection\ContainerBuilder->getDefinition() (line 690 of
/Users/tim/www/d8/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php).
Symfony\Component\DependencyInjection\Exception\InvalidArgumentException: The service definition "router.builder" does not exist. in Symfony\Component\DependencyInjection\ContainerBuilder->getDefinition() (line 690 of /Users/tim/www/d8/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php).
Drush command terminated abnormally due to an unrecoverable error.

Comments

#1

Project:Drush» Drupal core
Version:» 8.x-dev
Component:Core Commands» base system

Drush does a full bootstrap and then calls drupal_flush_all_caches(). I think that function is assuming a web request which is not always true. That function makes the fatal call to drupal_container(). Moving this bug to Drupal core.

#2

Title:Services cannot be retrieved from drupal_container() in most drush commands» drupal_flush_all_caches() assumes a web request - "The service definition "router.builder" does not exist. "

#3

This is yet another facet of the "Drupal doesn't work without a Kernel" problem, which is a factor in several issues. The solution to all of them is "always use a kernel". For command line, the ideal solution is "put the Console component in core, and use a kernel with it."

#4

#5

Status:active» fixed

I played with this a bit today and fixed the cache-clear problem by doing in drush a lot of what index.php is doing

     drupal_bootstrap(DRUPAL_BOOTSTRAP_CODE);
    // global $kernel;
    $kernel = new Drupal\Core\DrupalKernel('prod', drush_get_context('DRUSH_DEBUG', FALSE));
    $kernel->boot();

This instantiates an httpkernel which makes no sense for a cli request but works for now. Hopefully someone can share some pseudocode which lets us setup an App kernel or whatever is appropriate.

There is a similar error in drush site-install command but i can't bear to debug the installer right now. Anyway, this is now fixed for all drush commands that do full bootstrap.

#6

Status:fixed» closed (fixed)

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