diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index 9b041ea..864a9b3 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -124,6 +124,13 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface { protected $allowDumping; /** + * Whether the container can be loaded. + * + * @var bool + */ + protected $allowLoading; + + /** * Whether the container needs to be dumped once booting is complete. * * @var bool @@ -159,12 +166,16 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface { * @param bool $allow_dumping * (optional) FALSE to stop the container from being written to or read * from disk. Defaults to TRUE. + * @param bool $allow_loading + * (optional) FALSE to prevent that the kernel is attempted to be read from + * disk. Defaults to $allow_dumping. */ - public function __construct($environment, ClassLoader $class_loader, $allow_dumping = TRUE) { + public function __construct($environment, ClassLoader $class_loader, $allow_dumping = TRUE, $allow_loading = NULL) { $this->environment = $environment; $this->booted = FALSE; $this->classLoader = $class_loader; $this->allowDumping = $allow_dumping; + $this->allowLoading = isset($allow_loading) ? $allow_loading : $allow_dumping; } /** @@ -329,6 +340,7 @@ public function updateModules(array $module_list, array $module_filenames = arra foreach ($module_filenames as $name => $extension) { $this->moduleData[$name] = $extension; } + // If we haven't yet booted, we don't need to do anything: the new module // list will take effect when boot() is called. If we have already booted, // then reboot in order to refresh the serviceProvider list and container. @@ -382,7 +394,7 @@ protected function initializeContainer() { $class = $this->getClassName(); $cache_file = $class . '.php'; - if ($this->allowDumping) { + if ($this->allowLoading) { // First, try to load. if (!class_exists($class, FALSE)) { $this->storage()->load($cache_file); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 340b555..a120883 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -1094,7 +1094,7 @@ protected function rebuildContainer($environment = 'prod') { $request_stack = \Drupal::service('request_stack'); } - $this->kernel = new DrupalKernel($environment, drupal_classloader(), FALSE); + $this->kernel = new DrupalKernel($environment, drupal_classloader(), TRUE, FALSE); $this->kernel->boot(); // DrupalKernel replaces the container in \Drupal::getContainer() with a // different object, so we need to replace the instance on this test class.