diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index e7665a8..109ada4 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -40,6 +40,15 @@ class DrupalKernel extends Kernel implements DrupalKernelInterface { 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 @@ -187,7 +196,7 @@ protected function moduleData($module) { * 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); } @@ -224,10 +233,11 @@ protected function getClassName() { */ protected function initializeContainer() { $this->container = NULL; - $class = $this->getClassName(); - $cache_file = $class . '.php'; if ($this->storage) { + $class = $this->getClassName(); + $cache_file = $class . '.php'; + // First, try to load. if (!class_exists($class, FALSE)) { $this->storage->load($cache_file); @@ -237,13 +247,19 @@ protected function initializeContainer() { $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. - 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')) { - unset($this->container); - } + } + + if (isset($this->moduleList) && isset($this->newModuleList) && array_keys($this->moduleList) !== array_keys($this->newModuleList)) { + unset($this->container); + $this->moduleList = $this->newModuleList; + unset($this->newModuleList); + } + // Verify that the module list didn't change since the container was + // compiled. + elseif (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')) { + unset($this->container); } }