diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index cbb9118..8a6f518 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -789,9 +789,7 @@ protected function initializeContainer() { } // The container was rebuild successfully. - if ($this->containerNeedsRebuild) { - $this->containerNeedsRebuild = FALSE; - } + $this->containerNeedsRebuild = FALSE; $this->attachSynthetic($container); diff --git a/core/modules/system/src/Tests/DrupalKernel/ContainerRebuildWebTest.php b/core/modules/system/src/Tests/DrupalKernel/ContainerRebuildWebTest.php index 734328d..a9c0c91 100644 --- a/core/modules/system/src/Tests/DrupalKernel/ContainerRebuildWebTest.php +++ b/core/modules/system/src/Tests/DrupalKernel/ContainerRebuildWebTest.php @@ -35,4 +35,27 @@ public function testSetContainerRebuildWithDifferentDeploymentIdentifier() { $this->assertHeader('container_rebuild_indicator', 'new-identifier'); } + /** + * Tests container invalidation. + */ + public function testContainerInvalidation() { + + // Ensure that parameter is not set. + $this->drupalGet(''); + $this->assertHeader('container_rebuild_test_parameter', FALSE); + + // Ensure that after setting the parameter, without a container rebuild the + // parameter is still not set. + $this->writeSettings(['settings' => ['container_rebuild_test_parameter' => (object) ['value' => 'rebuild_me_please', 'required' => TRUE]]]); + sleep(5); + + $this->drupalGet(''); + $this->assertHeader('container_rebuild_test_parameter', FALSE); + + // Ensure that after container invalidation the parameter is set. + \Drupal::service('kernel')->invalidateContainer(); + $this->drupalGet(''); + $this->assertHeader('container_rebuild_test_parameter', 'rebuild_me_please'); + } + } diff --git a/core/modules/system/tests/modules/service_provider_test/src/ServiceProviderTestServiceProvider.php b/core/modules/system/tests/modules/service_provider_test/src/ServiceProviderTestServiceProvider.php index 9e21883..700c2ce 100644 --- a/core/modules/system/tests/modules/service_provider_test/src/ServiceProviderTestServiceProvider.php +++ b/core/modules/system/tests/modules/service_provider_test/src/ServiceProviderTestServiceProvider.php @@ -26,5 +26,9 @@ public function alter(ContainerBuilder $container) { if ($indicator = Settings::get('deployment_identifier')) { $container->setParameter('container_rebuild_indicator', $indicator); } + + if ($parameter = Settings::get('container_rebuild_test_parameter')) { + $container->setParameter('container_rebuild_test_parameter', $parameter); + } } } diff --git a/core/modules/system/tests/modules/service_provider_test/src/TestClass.php b/core/modules/system/tests/modules/service_provider_test/src/TestClass.php index cbbe773..bec97d2 100644 --- a/core/modules/system/tests/modules/service_provider_test/src/TestClass.php +++ b/core/modules/system/tests/modules/service_provider_test/src/TestClass.php @@ -51,6 +51,9 @@ public function onKernelResponseTest(FilterResponseEvent $event) { if ($this->container->hasParameter('container_rebuild_indicator')) { $event->getResponse()->headers->set('container_rebuild_indicator', $this->container->getParameter('container_rebuild_indicator')); } + if ($this->container->hasParameter('container_rebuild_test_parameter')) { + $event->getResponse()->headers->set('container_rebuild_test_parameter', $this->container->getParameter('container_rebuild_test_parameter')); + } } /**