From 165ba7eca0b723918d759f2480e74e9768b1eb74 Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Mon, 11 Mar 2019 16:31:52 +0000 Subject: [PATCH] Issue #2795789 by Fabianx, jibran, dawehner, alexpott: Do not rebuild the container so often in BTB --- .../lib/Drupal/Core/Test/FunctionalTestSetupTrait.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php index 6b4ce17693e6..46fea2f830b1 100644 --- a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php +++ b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php @@ -383,10 +383,13 @@ protected function initUserSession() { */ protected function initKernel(Request $request) { $this->kernel = DrupalKernel::createFromRequest($request, $this->classLoader, 'prod', TRUE); - $this->kernel->prepareLegacyRequest($request); + // Force the container to be built from scratch instead of loaded from the // disk. This forces us to not accidentally load the parent site. - return $this->kernel->rebuildContainer(); + $this->kernel->invalidateContainer(); + + $this->kernel->prepareLegacyRequest($request); + return \Drupal::getContainer(); } /** @@ -420,8 +423,8 @@ protected function installModulesFromClassProperty(ContainerInterface $container // The exception message has all the details. $this->fail($e->getMessage()); } - - $this->rebuildContainer(); + // The container was already rebuilt by the ModuleInstaller. + $this->container = \Drupal::getContainer(); } } -- GitLab