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 @@ -226,22 +226,26 @@ $class = $this->getClassName(); $cache_file = $class . '.php'; - // First, try to load. - if ($this->storage && !class_exists($class, FALSE)) { - $this->storage->load($cache_file); - } - // If the load succeeded or the class already existed, use it. - if (class_exists($class, FALSE)) { - $fully_qualified_class_name = '\\' . $class; - $this->container = new $fully_qualified_class_name; - } - - 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 ($this->storage) { + // First, try to load. + if (!class_exists($class, FALSE)) { + $this->storage->load($cache_file); + } + // If the load succeeded or the class already existed, use it. + if (class_exists($class, FALSE)) { + $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->container)) { $this->container = $this->buildContainer(); if ($this->storage && !$this->dumpDrupalContainer($this->container, $this->getContainerBaseClass())) {