diff --git a/core/modules/system/src/Tests/DrupalKernel/ContainerRebuildWebTest.php b/core/modules/system/src/Tests/DrupalKernel/ContainerRebuildWebTest.php new file mode 100644 index 0000000..734328d --- /dev/null +++ b/core/modules/system/src/Tests/DrupalKernel/ContainerRebuildWebTest.php @@ -0,0 +1,38 @@ +drupalGet(''); + $this->assertHeader('container_rebuild_indicator', FALSE); + + $this->writeSettings(['settings' => ['deployment_identifier' => (object) ['value' => 'new-identifier', 'required' => TRUE]]]); + + $this->drupalGet(''); + + $this->assertHeader('container_rebuild_indicator', 'new-identifier'); + } + +} diff --git a/core/modules/system/tests/modules/service_provider_test/service_provider_test.services.yml b/core/modules/system/tests/modules/service_provider_test/service_provider_test.services.yml index dda70f5..77e13dd 100644 --- a/core/modules/system/tests/modules/service_provider_test/service_provider_test.services.yml +++ b/core/modules/system/tests/modules/service_provider_test/service_provider_test.services.yml @@ -4,4 +4,5 @@ services: tags: - { name: event_subscriber } - { name: needs_destruction } + parent: container.trait arguments: ['@state'] 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 c3b14b3..9759e2c 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 @@ -9,6 +9,7 @@ use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\DependencyInjection\ServiceModifierInterface; +use Drupal\Core\Site\Settings; class ServiceProviderTestServiceProvider implements ServiceModifierInterface { @@ -21,5 +22,9 @@ public function alter(ContainerBuilder $container) { $definition = $container->getDefinition('file.usage'); $definition->setClass('Drupal\service_provider_test\TestFileUsage'); } + + if ($indicator = Settings::get('deployment_identifier')) { + $container->setParameter('container_rebuild_indicator', $indicator); + } } } 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 e46accd..a651ae8 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 @@ -9,11 +9,16 @@ use Drupal\Core\State\StateInterface; use Drupal\Core\DestructableInterface; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; -class TestClass implements EventSubscriberInterface, DestructableInterface { +class TestClass implements EventSubscriberInterface, DestructableInterface, ContainerAwareInterface { + + use ContainerAwareTrait; /** * The state keyvalue collection. @@ -40,6 +45,15 @@ public function onKernelRequestTest(GetResponseEvent $event) { } /** + * Flags the response in case a rebuild indicator is used. + */ + 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')); + } + } + + /** * Registers methods as kernel listeners. * * @return array @@ -47,6 +61,7 @@ public function onKernelRequestTest(GetResponseEvent $event) { */ static function getSubscribedEvents() { $events[KernelEvents::REQUEST][] = array('onKernelRequestTest'); + $events[KernelEvents::RESPONSE][] = array('onKernelResponseTest'); return $events; } diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php index 7c65bec..3516f77 100644 --- a/sites/default/default.settings.php +++ b/sites/default/default.settings.php @@ -296,7 +296,7 @@ * must only use characters valid in PHP function names as defined by * http://php.net/manual/en/functions.user-defined.php */ -$settings['deployment_identifier'] = \Drupal::VERSION; +# $settings['deployment_identifier'] = \Drupal::VERSION; /** * Access control for update.php script.