diff -u b/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php --- b/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -40,9 +40,18 @@ protected $moduleList; /** + * Holds an updated list of enabled modules. + * + * @var array + * An associative array whose keys are module names and whose values are + * ignored. + */ + protected $newModuleList; + + /** * An array of module data objects. * - * The data objects have the same datastructure as returned by + * The data objects have the same data structure as returned by * file_scan_directory() but only the uri property is used. * * @var array @@ -187,7 +196,7 @@ * Implements Drupal\Core\DrupalKernelInterface::updateModules(). */ public function updateModules(array $module_list, array $module_paths = array()) { - $this->moduleList = $module_list; + $this->newModuleList = $module_list; foreach ($module_paths as $module => $path) { $this->moduleData[$module] = (object) array('uri' => $path); } @@ -237,8 +246,14 @@ $fully_qualified_class_name = '\\' . $class; $this->container = new $fully_qualified_class_name; } - // Verify that the module list didn't change since the container was - // compiled. + // First check whether the list of modules changed in this request. + if (isset($this->container) && isset($this->moduleList) && isset($this->newModuleList) && array_keys($this->moduleList) !== array_keys($this->newModuleList)) { + $this->moduleList = $this->newModuleList; + unset($this->container, $this->newModuleList); + } + // Second, verify that some other request -- for example on another + // web frontend or during the installer -- changed the list of enabled + // modules. if (isset($this->container)) { $module_list = array_keys($this->moduleList ?: $this->container->get('config.factory')->get('system.module')->load()->get('enabled')); if ($module_list !== $this->container->getParameter('container.modules')) {