Loading core/core.services.yml +0 −4 Original line number Diff line number Diff line Loading @@ -1492,10 +1492,6 @@ services: class: Drupal\Core\StreamWrapper\TemporaryStream tags: - { name: stream_wrapper, scheme: temporary } kernel_destruct_subscriber: class: Drupal\Core\EventSubscriber\KernelDestructionSubscriber calls: - [setContainer, ['@service_container']] image.toolkit.manager: class: Drupal\Core\ImageToolkit\ImageToolkitManager arguments: ['@config.factory'] Loading core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php +2 −9 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; /** * Adds services with specific tags to "kernel_destruct_subscriber" service. * Adds services to the "kernel.destructable_services" container parameter. * * Only services tagged with "needs_destruction" are added. * Loading @@ -18,15 +18,8 @@ class RegisterServicesForDestructionPass implements CompilerPassInterface { * {@inheritdoc} */ public function process(ContainerBuilder $container) { if (!$container->hasDefinition('kernel_destruct_subscriber')) { return; } $definition = $container->getDefinition('kernel_destruct_subscriber'); $services = $container->findTaggedServiceIds('needs_destruction'); foreach ($services as $id => $attributes) { $definition->addMethodCall('registerService', [$id]); } $container->setParameter('kernel.destructable_services', array_keys($services)); } } core/lib/Drupal/Core/DrupalKernel.php +14 −7 Original line number Diff line number Diff line Loading @@ -685,15 +685,22 @@ public function getServiceProviders($origin) { * @return void */ public function terminate(Request $request, Response $response) { if ($this->getHttpKernel() instanceof TerminableInterface) { // Only run terminate() when essential services have been set up properly // by preHandle() before. if (FALSE === $this->prepared) { return; } if ($this->getHttpKernel() instanceof TerminableInterface) { if ($this->prepared === TRUE) { $this->getHttpKernel()->terminate($request, $response); } // For destructable services, always call the destruct method if they were // initialized during the request. Destruction is not necessary if the // service was not used. foreach ($this->container->getParameter('kernel.destructable_services') as $id) { if ($this->container->initialized($id)) { $service = $this->container->get($id); $service->destruct(); } } } } /** Loading core/lib/Drupal/Core/EventSubscriber/KernelDestructionSubscriber.php +3 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,9 @@ /** * Destructs services that are initiated and tagged with "needs_destruction". * * @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. There is no * replacement. * @see https://www.drupal.org/node/3416021 * @see \Drupal\Core\DestructableInterface */ class KernelDestructionSubscriber implements EventSubscriberInterface, ContainerAwareInterface { Loading core/modules/user/src/EventSubscriber/UserRequestSubscriber.php +1 −3 Original line number Diff line number Diff line Loading @@ -60,9 +60,7 @@ public function onKernelTerminate(TerminateEvent $event) { * {@inheritdoc} */ public static function getSubscribedEvents(): array { // Should go before other subscribers start to write their caches. Notably // before \Drupal\Core\EventSubscriber\KernelDestructionSubscriber to // prevent instantiation of destructed services. // Should go before other subscribers start to write their caches. $events[KernelEvents::TERMINATE][] = ['onKernelTerminate', 300]; return $events; } Loading Loading
core/core.services.yml +0 −4 Original line number Diff line number Diff line Loading @@ -1492,10 +1492,6 @@ services: class: Drupal\Core\StreamWrapper\TemporaryStream tags: - { name: stream_wrapper, scheme: temporary } kernel_destruct_subscriber: class: Drupal\Core\EventSubscriber\KernelDestructionSubscriber calls: - [setContainer, ['@service_container']] image.toolkit.manager: class: Drupal\Core\ImageToolkit\ImageToolkitManager arguments: ['@config.factory'] Loading
core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php +2 −9 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; /** * Adds services with specific tags to "kernel_destruct_subscriber" service. * Adds services to the "kernel.destructable_services" container parameter. * * Only services tagged with "needs_destruction" are added. * Loading @@ -18,15 +18,8 @@ class RegisterServicesForDestructionPass implements CompilerPassInterface { * {@inheritdoc} */ public function process(ContainerBuilder $container) { if (!$container->hasDefinition('kernel_destruct_subscriber')) { return; } $definition = $container->getDefinition('kernel_destruct_subscriber'); $services = $container->findTaggedServiceIds('needs_destruction'); foreach ($services as $id => $attributes) { $definition->addMethodCall('registerService', [$id]); } $container->setParameter('kernel.destructable_services', array_keys($services)); } }
core/lib/Drupal/Core/DrupalKernel.php +14 −7 Original line number Diff line number Diff line Loading @@ -685,15 +685,22 @@ public function getServiceProviders($origin) { * @return void */ public function terminate(Request $request, Response $response) { if ($this->getHttpKernel() instanceof TerminableInterface) { // Only run terminate() when essential services have been set up properly // by preHandle() before. if (FALSE === $this->prepared) { return; } if ($this->getHttpKernel() instanceof TerminableInterface) { if ($this->prepared === TRUE) { $this->getHttpKernel()->terminate($request, $response); } // For destructable services, always call the destruct method if they were // initialized during the request. Destruction is not necessary if the // service was not used. foreach ($this->container->getParameter('kernel.destructable_services') as $id) { if ($this->container->initialized($id)) { $service = $this->container->get($id); $service->destruct(); } } } } /** Loading
core/lib/Drupal/Core/EventSubscriber/KernelDestructionSubscriber.php +3 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,9 @@ /** * Destructs services that are initiated and tagged with "needs_destruction". * * @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. There is no * replacement. * @see https://www.drupal.org/node/3416021 * @see \Drupal\Core\DestructableInterface */ class KernelDestructionSubscriber implements EventSubscriberInterface, ContainerAwareInterface { Loading
core/modules/user/src/EventSubscriber/UserRequestSubscriber.php +1 −3 Original line number Diff line number Diff line Loading @@ -60,9 +60,7 @@ public function onKernelTerminate(TerminateEvent $event) { * {@inheritdoc} */ public static function getSubscribedEvents(): array { // Should go before other subscribers start to write their caches. Notably // before \Drupal\Core\EventSubscriber\KernelDestructionSubscriber to // prevent instantiation of destructed services. // Should go before other subscribers start to write their caches. $events[KernelEvents::TERMINATE][] = ['onKernelTerminate', 300]; return $events; } Loading